ECLAIR User’s Manual

About ECLAIR

The development of high-quality software is a tough task: ECLAIR has been designed to assist development and quality assurance teams to achieve that quality, as well as helping quality control teams assess its achievement.

What ECLAIR Is

ECLAIR is a powerful platform for the automatic analysis, verification, testing and transformation of C and C++ programs (with extensions to Java source code and bytecode, and possible extension to other languages).

ECLAIR is very flexible and highly configurable. It can support your software development workflow and environment, whatever they are.

ECLAIR is suitable for light verification tasks that can be run right on the developer’s desktop, as well as for tough semantics-based analyses to be run overnight.

ECLAIR is fit for use in mission- and safety-critical software projects: it has been designed from the outset to exclude false negatives unless the user’s configuration asks for them.

ECLAIR is developed in a rigorous way and carefully checked with extensive internal test suites (numbering tens of thousands of testcases) and industry-standard validation suites (such as Solid Sands SuperTest and The Plum Hall Validation Suite for C).

ECLAIR is based on solid scientific research results and on the best practices of software development.

ECLAIR is developed by a passionate team of experts. Please, do not hesitate to let us have your feedback: you may be surprised to discover just how much your suggestions matter to us.

What ECLAIR Is Not

ECLAIR is not something that will tell you which software analysis, verification and testing activities are appropriate in your field. In particular, it cannot tell you which coding rules are suited to your project. However, the programming language experts at BUGSENG can provide significant help in this respect.

ECLAIR is not a substitute for project management, even though it can be adapted to any software development practice, process and methodology.

ECLAIR Features at a Glance

Note

ECLAIR is a platform for software verification. The platform is instantiated, released and licensed in many different ways depending on the precise needs of each customer. The following description of ECLAIR features is completely general and does not necessarily reflect the functionality of the ECLAIR instance that was licensed to you: see your license for the applicable details.

Automatic Checking of Coding Standards

ECLAIR provides support for automatically checking conformance with respect to a number of widely-used coding standards, including:

  • AUTOSAR C [30]

  • Barr Group C [8];

  • CERT C Secure Coding Standard 1.0 [27];

  • CERT C Secure Coding Standard 2.0 [15];

  • CERT C++ Secure Coding Standard [14];

  • Delphi C [2];

  • ESA/BSSC C/C++ [16];

  • EC– [19];

  • High-Integrity C++ [17];

  • Industrial Strength C++ [20];

  • IPA ESCR C [66, 68];

  • IPA ESCR C++ [67];

  • JSF C++ [1];

  • MISRA-C:1998 [60];

  • MISRA-C:2004 [62];

  • MISRA C:2012 [45];

  • MISRA C++:2008 [64];

  • NASA/JPL C [3];

  • Nokia Qt (C++) [21, 22];

  • Philips Healthcare (C++) [31];

  • The Power of Ten (C) [23].

In addition to these, BUGSENG has developed checkers to verify conformance with respect to several other coding standards, including proprietary company standards and project-specific standards. Coding rules are checked with very general and accurate checkers, which operate on the precise sequences of tokens and abstract syntax trees that are manipulated by the compiler.

Coupled with the fact that ECLAIR always checks each rule in the appropriate context (at the token, declaration, translation unit, whole program or whole system levels), this makes sure that the checkers for decidable rules are exact (neither false positives nor false negatives). For undecidable rules, ECLAIR provides different checkers characterized by different solutions to the tradeoff among computational complexity, number of false positives and number of false negatives [6]. In any case, when false negatives are possible, they are always clearly and unambiguously delimited.

This is in sharp contrast with checkers that are based on pattern matching and imprecise parsing. If, on the one hand, they can deal with programs that do not compile, on the other hand they are plagued by a high number of false positives and, most importantly, false negatives, something that makes them unsuitable to safety-critical and mission-critical contexts. Generally speaking, beware of tools based on obsolete technology: directives such as 90/385/EEC and 93/42/EEC in the medical sector assert that compliance can only be claimed if the generally acknowledged state-of-the-art is followed.

ECLAIR can be configured to produce a variety of outputs:

  • for immediate or later browsing using the very powerful ECLAIR-integrated web-based browser;

  • for immediate browsing, with certain license kinds, in popular IDEs like Eclipse or Microsoft Visual Studio®, MPLAB® X IDE, NetBeans, IAR Embedded Workbench®, IntelliJ IDEA, CLion, Texas Instruments Code Composer Studio™, Visual Studio Code, Keil μVision®, or any suitable editor;

  • for the automatic insertion into issue-tracking systems or any other database;

  • for the automatic production of compliance matrices required to meet industrial standards and guidelines such as IEC 61508, ISO 26262 (automotive), CENELEC EN 50128 (railway), DO-178B/C (aerospace), IEC 60880 (nuclear power), IEC 62304 and FDA norms (medical).

Metrics

For assessing the complexity, readability and maintainability of software, ECLAIR provides comprehensive metrics about the code including the fundamental set defined by the HIS Source Code Metrics [13] document and many of the requirements of the SQALE Method [24] quality model. These measures may be incrementally reported, showing exactly where in the code the value was computed, or aggregated (e.g., maximized, summed, averaged) over a single function, translation unit, program or the whole project.

Semantic Analysis

ECLAIR is equipped with powerful constraint propagation, symbolic model checking, and abstract interpretation engines. Their combined use allows different compromises between computational complexity and precision, so that users can select an optimal cost-benefit tradeoff with respect to their objectives. On the developer’s desktop, only quick analyses are appropriate; but when the alternative is between, e.g., proving absence of run-time errors by hand or by machine, 12 hours of computation time is nothing: ECLAIR has been designed to support the entire spectrum between these two extremes.

Automatic Unit Test Case Generation

ECLAIR can automatically synthesize minimal sets of unit test inputs that reach a specified coverage criterion (or prove that such coverage cannot be reached due to unfeasible conditions in the program). If a human or mechanized “oracle” is available to predict the expected output, then complete unit tests can be synthesized in a fraction of the time required for manual generation.

Other Applications

Semantic matchers and patchers, simplifiers, obfuscators, translators, … these are just a few examples of the plethora of applications that, because of ECLAIR’s highly modular design, can be developed relatively easily at the right level of abstraction.

Proper Integration with the Toolchain

ECLAIR intercepts every invocation of the toolchain components (compilers, linker, assembler, archive manager) and it automatically extracts and interprets the options that the build system has passed to them. This allows for the seamless integration with any build system. Moreover, the user does not need to engage in error-prone activities such as:

  • specifying which files compose the application and where the right header files are located;

  • configuring the static analyzer so that the analysis parameters match the options given to the compilers (several options do affect the program semantics).

All this is automatic and supports build processes that involve the automatic generation of source files that depend on the configuration, without requiring the development and maintenance of a separated analysis procedure: with ECLAIR the existing build procedure can be used verbatim.

One of the key properties of ECLAIR is that it understands all the analysis-relevant options of the supported compilers. The language used to abstractly model such options is so powerful that adding support for a new compiler is no longer a problem.

Web-Based Configuration Interface

All the verification tasks supported by ECLAIR can be specified and refined incrementally by means of a very convenient graphical user interface.

Precise Parsing of Source Files

ECLAIR includes a state-of-the-art parser for C and C++ languages. In particular, for:

  • the pre-standardization K&R C dialect;

  • the standardized C languages (C90, C99, C11 and C18);

  • the standardized C++ languages (C++98, C++03, C++11 and C++14, as well as a good portion of C++17 and C++20);

  • the language extensions of the GNU C/C++ dialects;

  • the language extensions of the Microsoft C/C++ dialects.

The parser produces an accurate abstract syntax tree (AST) representing all of the information available in the analyzed code. Accuracy means, among other things, that:

  • the AST represents not only the explicit, but also all of the implicit language constructs in the source code: implicit type conversions, compiler-generated functions (e.g., for constructors and destructors), instantiations of function/class templates, etc.;

  • all language constructs are provided with precise location information, enabling the generation of reports to point to the exact sources.

Source location information is not only precise, but also thorough:

  • complete information is available for the chain of file inclusions and, orthogonally, for the chain of macro expansions that enable a lexical token (in the written program) to become a part of the analyzed source code;

  • the well-known difficulty of tracking problems in implicit template instantiations is solved presenting to the user complete yet easily readable information about the full instantiation chain.

Supported Platforms and Development Environments

ECLAIR is available on most modern flavors of UNIX®, Linux, macOS® and Windows®, including Cygwin and MinGW, and can be used with just about any development environment. Thanks to its ability to intercept the toolchain components, it supports virtually any makefile-based, script-based or hybrid build systems. ECLAIR can leverage the availability of computing resources by supporting parallel and distributed program analyses. Most popular C/C++ compilers and cross compilers are supported, including ARM®, CodeWarrior™, Cosmic Software, CrossWorks™, Emscripten, GCC and its derivatives, Green Hills®, HighTec, IAR™, Intel®, Keil Software®, Microsoft®, MPLAB®, QNX™, Renesas Electronics, SOFTUNE™, TASKING®, Texas Instruments™, Wind River®, as well as clang/LLVM and its derivatives.

ECLAIR Is Protected Commercial Software

The entire ECLAIR system is protected commercial software owned by BUGSENG srl. Any reproduction or redistribution of any part of the ECLAIR system not in accordance with the License Agreement is expressly prohibited by law, and may result in severe civil and criminal penalties. Violators will be prosecuted to the maximum extent possible.

Without limiting the foregoing, copying or reproduction of any part of the ECLAIR system to any server or location for further reproduction or redistribution is expressly prohibited. The extensive and systematic use of digital watermarking techniques ensures that each delivered version of ECLAIR, or part thereof, can always be traced back to the original authorized recipient.

Disclaimer

Nobody Can Prove that an Arbitrary Program is Bug-Free

Consider the following C/C++ function:

 1typedef unsigned long T_uint64;
 2
 3T_uint64 gcd(T_uint64 a, T_uint64 b);
 4
 5T_uint64 gcd(T_uint64 a, T_uint64 b) {
 6  if (a != 0UL) {
 7    while (b != 0UL) {
 8      if (a > b) {
 9        a = a - b;
10      }
11      else {
12        b = b - a;
13      }
14    }
15  }
16  return a;
17}

The above function is probably meant to compute the greatest common divisor of two numbers… or perhaps the general content descriptor of… or maybe something related to the grand central dispatch… who can know for sure? Certainly ECLAIR can’t. When given the above piece of code (and nothing else) a suitable version of ECLAIR can do the following, if configured to that effect:

  • check that the code conforms to widely adopted, industrial-strength sets of coding rules;

  • check that the code does not give rise to integer overflows (which, even though well-defined for unsigned integers, are often unwanted);

  • check that some specified assumptions always hold;

  • check that gcd(x, y) will always terminate, no matter what the value of x and y might be;

  • generate unit tests that will satisfy a user-specified coverage criterion.

So, in general, ECLAIR will be able to check the consistency between the code itself or its behavior and some explicitly specified expectations. Although this leads to a dramatic reduction in the number of bugs and helps produce the best possible software, it is not a proof that the program or the expectations are bug-free. Indeed, proving that an arbitrary program is bug-free is an unfeasible task (this was established in the 1930s by Kurt Gödel and Alan Turing).

The moral is: beware of a false sense of security that might result from the use of a powerful tool like ECLAIR. ECLAIR can do a lot to help you making your software safe and secure, but it cannot prove that your software is bug-free.

False Positives and False Negatives

All the users of all program analysis tools may be confronted with a false positive or a false negative.

These may be due to a misunderstanding between the user and those who designed or configured the tool. In many cases the misunderstanding is neither the fault of the user nor of the designers/configurators; just note that all versions of the C and C++ standards have hundreds of documented ambiguities and that most coding rules are ambiguous as well and a constant subject of debate.

False positives and negatives may also be due to fundamental laws of nature: most interesting semantic properties of programs are undecidable so that no tool can avoid both false positives and false negatives for those properties [6]. In other words, those properties can only be approximated. Depending on the application and the desired cost/precision tradeoff two kinds of approximations are commonly employed:

  • quick-to-compute ones possibly resulting into false negatives but no false positive;

  • more expensive ones possibly resulting into false positives but no false negatives.

As an example, consider flagging the presence of unreachable code. Since the termination of loops is undecidable there will never be a tool that will flag all, and only all unreachable code in arbitrary programs. But one can:

  • find some definitely unreachable code using quick syntactic analyses (e.g., a statement immediately following a return statement is unreachable) and ignore loops, either by remaining silent about them (resulting into false negatives) or by flagging all code immediately following them as possibly unreachable (resulting into false posities);

  • do a deep semantic analysis of loops which, despite its depth, will by necessity be inconclusive for some loops and the tool will either flag the code immediately following them as possibly unreachable (resulting, again, into false positives), or not flag it (resulting, again, into false negatives).

Summarizing, the user should be aware of the properties of the checker and of the configuration chosen to analyze the program. Note also that there is a fundamental asymmetry between false positives and false negatives: you can silence a positive you believe is false, but there is nothing you can do about a false negative.

The Fine Print

For a period of 45 (forty five) days from the date of delivery BUGSENG warrants that the software provided has, to BUGSENG’s knowledge, no code that is intended to damage the software and/or the software systems of the licensee.

BUGSENG warrants that the media used to deliver the software is not defective and that a cryptographic digital signature hash will be communicated to allow the licensee to verify content integrity. If, for a period of 45 days (forty five) from the date of delivery, the software media shall prove to be corrupted, BUGSENG will replace them without charge once received back the original media.

BUGSENG warrants that the software provided to the licensee does not violate third-party rights and that it conforms to specifications contained in present document. All discrepancies between the software provided and the present document that are notified in writing to BUGSENG during the period of validity of the maintenance contract and confirmed by BUGSENG personnel will be corrected without charge and without any licensee indemnification.

These are limited warranties and are the only warranties made by BUGSENG; BUGSENG makes no other express or implicit warranty including, without limitation, warranties of merchantability and of fitness for a particular purpose.

Contact Us

Offices

Parma (headquarters):
BUGSENG srl
Via Marco dell’Arpa 8/B
I-43121 Parma
Italy
Pisa:
BUGSENG srl
Via Fiorentina 214/C
I-56121 Pisa (PI)
Italy

Email Addresses

General Information:

info@bugseng.com

Sales Inquiries:

sales@bugseng.com

Technical Support:

support@bugseng.com

Training Inquiries:

training@bugseng.com

Consulting Inquiries:

consulting@bugseng.com

Qualification Inquiries:

qualification@bugseng.com

Evaluation Inquiries:

eval@bugseng.com

Partner Inquiries:

partners@bugseng.com

Job Opportunities:

jobs@bugseng.com

Administration:

admin@bugseng.com

Data Protection and GDPR:

privacy@bugseng.com

Customer Support Portal

http://bugseng.com/ contains more contact options, including authenticated access to the issue-tracking system.

BUGSENG Services

BUGSENG provides, among others, services in the following areas:

Custom Checkers

Development of ECLAIR checkers for the automatic verification of conformance with respect to customer-defined coding rules.

Process Integration

On-line/on-site assistance with the installation of ECLAIR and its integration with the customer’s development and build environments.

Training

On-line/on-site training for software developers, build engineers, quality control staff and tool administrators. Courses are designed to ensure participant engagement and to assist long-term retention; they also come with one month of free remote consultancy on the course topics. As an example, check out the detailed description of the Effective MISRA-C course available at http://bugseng.com/

Software Audit Reviews

Assistance in the definition of coding standards; evaluation of defects in the customer’s or suppliers’ code with respect to coding standards; assistance in the definition of a work plan to gradually bring the code base into conformance.

Complex Software Transformations

Leveraging the power of ECLAIR, assistance with the partial automatization of complex refactorings, including the porting to 64-bit architectures and to Unicode text representations.

Changes from Previous Versions

In this chapter we summarize the main changes to each version of ECLAIR from the version before it. Note that major versions can (and often do) contain incompatible changes, so please make sure to read the following carefully. Please do not hesitate to contact BUGSENG for assistance on the upgrade process.

Summary of Changes from Version 3.13.1 to Version 3.14.0

ECLAIR version 3.14.0 contains new features, many enhancements to existing features, and the correction of several defects.

New features (FSSCF):
  • New versioning scheme simplifies working with the many published versions of MISRA C:2012/2023/2025, including revisions, amendments and technical corrigenda. Now the latest version of, say, MISRA C Rule 21.8 (i.e., the one in MISRA C:2025) is available under MC4.R21.8, the version in MISRA C:2023 is available under MC3.R21.4 and the version after MISRA C:2012 TC1 and before MISRA C:2012 AMD2 is available under MC3R1.R21.8 (where “R1” is short for “Revision 1”) and MC3C1.R21.8 (where “C1” is short for “TC1”). MISRA C:2004 checkers are available under the MC2 prefix (e.g., MC2.14.5) whereas MISRA C:1991 checkers are available under the MC1 prefix (e.g., MC1.32).

  • New service B.FRAMES to verify conditions on the invoked toolchain components and the options passed to them.

  • Now ECLAIR intercepts all supported toolchain components by default. Advanced users can limit interception to selected components (via environment variables CC_ALIASES, CXX_ALIASES, AS_ALIASES, LD_ALIASES, AR_ALIASES, FILEMANIP_ALIASES) and prevent interception of selected components (via environment variables CC_NALIASES, CXX_NALIASES, AS_NALIASES, LD_NALIASES, AR_NALIASES, FILEMANIP_NALIASES). The environment variables CC, CXX, LD, AS, AR and FILEMANIP are now ignored.

  • New eclairit driver allows for greatly simplified ECLAIR use.

  • Added support for MISRA C:2012 Amendment 4, MISRA C:2023 and MISRA C:2025.

  • Added support for MISRA C++:2023.

  • Added new tool Scout (service B.SCOUT) to assess the usage of C/C++ entities within a program.

  • Added support for MISRA C:2012/2023 Appendix E, which recategorizes some MISRA C guidelines when applied to automatically generated code.

  • The ECLAIR parser has been updated to support the most recent versions of C and C++.

  • New service B.UNEVALEFF to report unevaluated side effects inside uses of the typeof, sizeof and alignof operators in C/C++.

  • Added metrics B.CMNTLINE_JFUNC and B.COMF_JFUNC that calculate, respectively, the numer of comment lines assogiated to a function and the ratio of comment lines and logical source lines of code in a function.

Other new features:
  • Added new tool eclair_import to generate XML reports from textual output generated by build systems that can be imported into ECLAIR databases.

  • New ECLAIR Bug Finder services for security have been added.

Enhancements and corrections of existing features and services (FSSCF):
  • Service STD.emptrecd is subsumed by STD.anonstct, therefore it has been removed. The service configurations of JC1.1, MC1.1, MC2.1.1, MC3.R1.1, MC3.R1.2, MP1.1-0-1, MP2.4.1.1, NC3.1.1.a are also affected by this change.

  • Fixed false positives for services MC3.D1.1, MC2.12.2, MC3.R1.5, MC3.R5.3, MC3.R13.2, MC3.R10.1, MC3.R17.7, MC3.R18.2, MC3.R18.6, MP1.5-0-1, NC3.3.3.b, MC3.R20.7, B.CALL.noeffect.

  • Fixed false negatives for services: MC2.R9.1, MC3.R9.1, MC3.R17.2, MC3.R18.2, MP1.0-1-7, MP1.3-2-4, MP1.7-5-4.

  • Service MC3.R7.4 now takes into account the exception introduced by MISRA C:2012 Technical Corrigendum 2.

  • Improved configurability of service MC3.R13.1: added the possibility to tag reports based on the effects found by the analysis.

  • Services STD.nstddirv service and STD.prepdirc have only some minor differences, but they check for the same thing: they are merged into a single service STD.prepdirc.

  • Corrected the semantics of the –accept option to the Un*x installers.

  • Floating point max/min are now printed using finite decimal floating point notation.

  • ECLAIR CerTran has been updated to work with SuperTest Aelbert Cuyp 5.0 Release.

  • Improved deviation mechanism for services: MC3.R5.5 and MC3.R5.7.

  • The clarity of reports involving initializer lists has been improved; this improves services: MC3.R10.1, MC3.R10.2, MC3.R10.3, MC3.R10.4, MC3.R10.5, MC3.R10.6, MC3.R10.7, MC3.R10.8, MC3.R11.7, MC3.R12.2, MC3.R14.4, MC3.R16.7, MC3.R23.6, MP1.4-5-1, MP1.4-5-2, MP1.4-5-3, MP1.5-0-10, MP1.5-0-11, MP1.5-0-12, MP1.5-0-13, MP1.5-0-14, MP1.5-0-20, MP1.5-0-21, MP1.5-0-3, MP1.5-0-4, MP1.5-0-6, MP1.5-0-8, MP1.5-0-9, MP1.5-3-1, MP1.5-3-2, MP1.5-8-1, MP1.6-4-7, MP1.7-2-1, NC3.5.3.c NC3.5.6.a.

  • Improved configurability of -stmt_selector; this affects all services using it.

  • Improved report description of service B.CALL.noeffect.

  • Corrected the report counting of “unfixed” reports for kinds other than violation, caution, information or metric in differential analyses.

  • Fixed some rare crashes affecting services MC3.R21.18 and MC3R1.R21.18.

  • Changed default setting for global -call_properties to consider points-to analysis set to be consisting of all possible locations.

  • Allow matching opaque types by selecting by matching the type, rather by matching the name.

  • Extend service MC3.R2.6 to take in account GCC attribute __attribute__((unused)).

  • Corrected the -call_properties global configuration type so as not to desugar its argument by default.

  • Added the possibility of selecting a function call via -call_selector using a statement selectors.

  • Fixed service kind from “rule” to “directive” for the following services: MC3.D1.1, MC3.D2.1, MC3.D3.1, MC3.D4.1, MC3.D4.2, MC3.D4.3, MC3.D4.4, MC3.D4.5, MC3.D4.6, MC3.D4.7, MC3.D4.8, MC3.D4.9, MC3.D4.10, MC3.D4.11, MC3.D4.12, MC3.D4.12, MC3.D4.13, MC3.D4.14, MC3.D4.15.

  • Improved configurability of service MC3.R16.6 with the possibility of specifying a minimum or maximum number of switch clauses that trigger a report.

  • Improved configurability of area selector to allow statements to be matched.

  • Reports for service MC3.R2.1 concerning switch statements have been improved.

  • Configurability of the -call_properties global configuration has been enhanced to express more fine-grained assumptions about the impact of a function call.

  • The distribution technology used to package eclair_certran has been uniformed to that used by other Python-based tools.

  • Updated and extended mapping from MISRA C:2023 guidelines to CERT-C:2016 rules and CWE weaknesses.

  • The “ECLAIR Project Organization Checker” has been renamed to “ECLAIR Independence Checker”. The service identifier B.INDEPENDENCE shall be used instead of B.PROJORG, which is deprecated but still available as an alias.

  • Improved global configuration -context_selector to add a few configuration alternatives that may be useful in services that depend on on this selector.

  • Renamed the base matcher decl(ENTITY_MATCHER) of global -type_selector to entity(ENTITY_MATCHER).

  • Improved performance for services MC3.D4.5, MC3.R5.2, MC3.R5.3, MP1.2-10-1, MP1.2-10-2, MP1.2-10-6, STD.nexidsig.

Other enhancements and corrections of existing features and services:
  • Changed eclair_report colors to better reflect the severity of the report.

  • Improved report descriptions.

  • Updated eclair_reqman to a more recent version of StrictDoc.

  • Updated eclair_format dependencies to the newest versions.

  • Updated and improved the ECLAIR Qualification Kit.

Newly supported toolchains (FSSCF):
  • Added support for Renesas CC-RX toolchain.

Enhancements of support for already-supported toolchains (FSSCF):
  • Added support for IAR Embedded Workbench 9.50.2.

  • Updated support for newest version of Renesas CC-RL and CC-RX.

  • Updated support for the newest version of ESP-IDF toolchain.

  • Correctly handle implicit option –cmse on IAR ARM compiler.

  • Improved support for Tasking ctc compilers.

  • Extended support for GCC-based compilers up to version 14.

  • Extended support for QNX SDP up to version 8.0.

  • Improved support for clang-based compilers.

  • Improved support for the Freescale S12Z compiler.

Enhancements and additions to the ECLAIR User’s Manual:
  • Documented the use of ECLAIR_* variables of the the ECLAIR GUI.

  • Improved documentation of service MC3.R12.1 and operator precedence.

  • Improved documentation of global configuration -context_selector.

Enhancements and corrections to the ECLAIR GUI:
  • Added a new advanced mode: by default the GUI now starts in simple mode.

  • Other usability and documentation improvements.

Enhancements and additions to collateral documentation:
  • All guides and brochures have been updated.

  • Updated and improved the ECLAIR Qualification Kit documentation.

Enhancements to license-enforcing mechanisms:
  • Updated the protection mechanisms to Sentinel LDK 10.13.

  • The eclair_licman program has been improved with inspective features: now it can list the Sentinel keys, features and products along with their attributes and properties (-S option).

Enhancements to the integrations with IDEs:
  • Updated the IntelliJ plugin to support the most recent versions of the IDE.

Summary of Changes from Version 3.13.0 to Version 3.13.1

ECLAIR version 3.13.1 contains only minor fixes and documentation improvements.

Enhancements of support for already-supported toolchains (FSSCF):
  • Improved support for “armcc” Keil v5 toolchains: fixed B.PARSER errors caused by inclusions of “stdio.h” and “stdarg.h” (in this order) and by expressions with bracket nesting level higher than 256.

Enhancements and corrections of existing features and services (FSSCF):
  • Fixed service B.TEXTFIND matching ranges in compliance with their specification.

  • Fixed crashes in services MC1.109, MC2.18.2, MC3.R19.1, MC3R1.R19.1, MC3R1.R23.1, MC3R1.R23.7 and MP1.0-2-1.

  • Fixed false positives potentially affecting all services that depend on the recognition of unevaluated contexts, most notably services MC3.R2.1 and MC3R1.R2.1.

  • Improved quality of implementation of services B.AUTOINIT, CC2.EXP33, MC1.30, MC2.9.1, MC3.R9.1, MP2D1.152 MC3R1.R9.1, MP1.8-5-1 and NC3.7.2.a.

Enhancements and additions to collateral documentation:
  • Added a FAQ about the compatibility of the ECLAIR GUI with legacy Linux-based operating systems.

Enhancements and corrections to the ECLAIR GUI:
  • Fixed crash in the ECLAIR GUI that caused the interface to become blank and unresponsive.

Summary of Changes from Version 3.12.0 to Version 3.13.0

ECLAIR version 3.13.0 contains new features, many enhancements to existing features, and the correction of several defects.

Note

Starting from this version, the summary of changes uses the acronym FSSCF, from Functional Safety and Security Certified Feature, in order to distinguish certified/qualifiable features from other features.

New features (FSSCF):
  • Added service B.CERTRAN, basis of a new stand-alone product for the automation of compiler qualification in compliance with functional safety standards.

  • Added service B.MACROS, for the reporting of the macros defined in a particular build (essential for ascertaining that the right configuration has been built).

  • Added service B.REQMAN, for the automatic checking of the traceability between requirements and program entities (this is a clone of existing MISRA C:2012 services MC3.D3.1 and MC3R1.D3.1).

  • Added service B.TEXTFIND, a powerful, user-controllable search facility for the automation of tasks such as the recognition of SPDX identifiers.

  • Added support for MISRA C:2012 Amendment 3, including the addition or revision of the following services: MC3R1.D4.15, MC3R1.R1.5, MC3R1.R6.3, MC3R1.R7.5, MC3R1.R8.15, MC3R1.R8.16, MC3R1.R8.17, MC3R1.R17.9, MC3R1.R17.10, MC3R1.R17.11, MC3R1.R17.12, MC3R1.R17.13, MC3R1.R18.9, MC3R1.R21.22, MC3R1.R21.23, MC3R1.R21.24, MC3R1.R23.1, MC3R1.R23.2, MC3R1.R23.3, MC3R1.R23.4, MC3R1.R23.5, MC3R1.R23.6, MC3R1.R23.7, MC3R1.R23.8.

  • Added support for MISRA C:2012 TC2.

  • Added support for MISRA C:2012 Deviation Permits.

  • Added support for the MISRA C:2012 rationale-based classification: this allows subsetting and prioritizing the work on MISRA compliance for projects with different requirements.

Other new features:
  • Added a tagging system for mapping CWE weaknesses to MISRA guidelines.

  • Added a tagging system for mapping CERT-C:2016 rules and recommendations to MISRA guidelines.

  • Added a requirement management tool distributed and installed along with ECLAIR.

  • Added MISRA C++:2023 services: MP2D1.23, MP2D1.25, MP2D1.42, MP2D1.43, MP2D1.45, MP2D1.46, MP2D1.47, MP2D1.81, MP2D1.82, MP2D1.83, MP2D1.94, MP2D1.103, MP2D1.105, MP2D1.106, MP2D1.107, MP2D1.133, MP2D1.134, MP2D1.135, MP2D1.143, MP2D1.145, MP2D1.146, MP2D1.147, MP2D1.148, MP2D1.149, MP2D1.152, MP2D1.158, MP2D1.159, MP2D1.162, MP2D1.163, MP2D1.165, MP2D1.171, MP2D1.187, MP2D1.191, MP2D1.194, MP2D1.196, MP2D1.199, MP2D1.203, MP2D1.204, MP2D1.207, MP2D1.210, MP2D1.211, MP2D1.212, MP2D1.220, MP2D1.224, MP2D1.225, MP2D1.226, MP2D1.228, MP2D1.301, MP2D1.320, MP2D1.321, MP2D1.325, MP2D1.359, MP2D1.387, MP2D1.395, MP2D1.396, MP2D1.397, MP2D1.403.

  • Reports now are tagged with the frames that trigger the analysis: this greatly facilitates analysis of violations involving macros that are expanded differently in different translation units.

  • The eclair_format program has been extended and improved: it now supports arbitrary user configurations.

  • Added the possibility to compile ECL files and added eclair_env options -config_file, -load_config and -save_config in order to work with compiled ECL files: this facility provides significant speedups in the case of large ECL configurations.

  • Added eclair_report option -server_ext that allows serving arbitrary contents.

  • Added eclair_report commands to export tables from an ECLAIR database in XSLT, XML, PROTOBUF, JSON and YAML formats.

  • Added eclair_report options -add_data and -clean_data allowing the addition and removal of arbitrary data to and from an ECLAIR database.

  • Added eclair_report option -load_xml to permit loading of third-party reports into an ECLAIR database: this allows browsing reports from different sources in a consistent way.

  • Added message-based selectors to -loc_selector and -area_selector: now it is possible to use regular expressions on areas and locations messages.

Enhancements and corrections of existing features and services (FSSCF):
  • Improved the internal C/C++ parser.

  • Improved the support for C++ lambda expressions.

  • Improved support for long paths in Windows.

  • Improved the taken call property: now it is possible to specify the property for each argument index (maybe/never/always).

  • Adapted service MC3R1.R21.21 to work with C++ code.

  • Fixed bug in the tagging system for services MC3.D4.5, MC3R1.D4.5, MC3.R9.1 and MC3R1.R9.1.

  • Fixed false positives for services NC3.3.4, NC3.4.3.b, NC3.8.6.a, MC3.D3.1, MC3R1.D3.1, MC3.D4.7, MC3R1.D4.7, MC3.D4.9, MC3R1.D4.9, MC3.R1.1, MC3R1.R1.1, MC3.R2.1, MC3R1.R2.1, MC3R1.R2.2, MC3.R5.6, MC3R1.R5.6, MC3.R8.3, MC3R1.R8.3, MC3.R9.1, MC3R1.R9.1, MC3.R9.3, MC3R1.R9.3, MC3.R14.3, MC3R1.R14.3, MC3.R17.8, MC3R1.R17.8, MP1.0-1-2, MP1.2-7-1, MP1.3-4-1, MP1.5-0-12, MP1.16-0-4, MP1.16-0-8 and STD.implfunc.

  • Services MC3.D3.1 and MC3R1.D3.1 have been improved.

  • Fixed false negatives for services NC3.4.3.b, MC3.D4.9, MC3R1.D4.9, MC3.D4.10, MC3R1.D4.10, MC3.R1.3, MC3R1.R1.3, MC3.R5.6, MC3R1.R5.6, MC3.R8.3, MC3R1.R8.3, MC3.R9.1, MC3R1.R9.1, MC3.R9.3, MC3R1.R9.3, MC3.R21.12, MC3R1.R21.12, MP1.0-1-2, MP1.2-7-1, MP1.3-1-1, MP1.7-5-4, MP1.8-4-2, MP1.15-3-3, MP1.16-0-8 and MP1.16-2-3.

  • Revised Harrison cyclomatic complexity definition computed by metric service HIS.v_G.

  • Fixed crashes of services MC1.18, MP1.14-6-1 and MP1.14-7-1.

  • Fixed bug in service STD.inclqote: the service configurations behavior did not allow the standard identification c95.

  • Fixed bug in services MC3.R18.6 and MC3R1.R18.4: the bug caused the misinterpretation of call properties defined with -call_properties in case of indirect calls.

  • Avoided duplicated tagging areas for many services.

  • Improved tagging system for MC3.R1.2 and MC3R1.R1.2: now they can accept any tag.

  • Improved report selector handling.

  • Added entity-based tagging for services MC3.R2.1 and MC3R1.R2.1.

  • Improved the efficiency of all services that require points-to analysis.

  • Improved the analysis accuracy of all services that check the use of enumeration constants in case statements.

  • Improved messages of services MC3.R14.2 and MC3R1.R14.2.

  • Improved performance of service B.PROJORG.

  • Improved the analysis accuracy of all services that check asm effects.

  • Improved quality of implementation of services that require macro arguments tracking.

  • Improved quality of implementation of services MC3.R8.3 and MC3R1.R8.3.

  • Improved quality of implementation of service B.CBT: now the service reports warnings if a label is used or declared multiple times.

  • Improved quality of implementation of services MC3.R2.1 and MC3R1.R2.1: now the services allow easily deviating branches that are intentionally unreachable.

  • Improved quality of implementation of service STD.charescp: now it checks preprocessed tokens instead of source-code ones.

  • Improved quality of implementation of service MP1.3-4-1: now the service reports all the declarations of entities to be moved; improved service messages.

  • Improved quality of implementation of services NC3.8.6.a: now the service uses stmt_matchers in its configurations.

  • Improved quality of implementation of service MC3R1.R9.1: removed avoidable cautions due to macro calls.

  • Improved configurability of services MC3.R2.1 and MC3R1.R2.1: now it is possible to deviate particular statements and the services report the statements causing the unreachability.

  • Improved configurability of service MP1.3-4-1: now it is possible to ignore const variables.

  • Improved internal utilities for checkers that require a flow-reachability analysis.

  • Fixed B.PARSER errors due to conversions from _Atomic to non-_Atomic types.

  • Fixed crash due to non standard uses of flexible array members.

  • Improved quality of implementation of services MC3.D4.9 and MC3R1.D4.9: now the checkers do not report macros where the typeof macro is used on an expression where a macro parameter occurs (while the macro can theoretically be replaced by several inline functions, the code quality will clearly suffer).

  • The __public_api_decls selector no longer requires external linkage.

Other enhancements and corrections of existing features and services:
  • Fixed missing cache reloading after changes to the database in the interactive reports view.

  • Improved quality of implementation of service B.CMPREXPR-01: now the service uses stmt_matchers in its configurations.

  • Improved the “unknown tool” warning of eclair_env: now the message specifies the tool kind.

  • Improved the macro expansion tracing feature.

  • Fixed crashes in eclair_format.

  • Updated eclair_format dependencies.

Newly supported toolchains (FSSCF):
  • Added support for Intel FPGA - NIOS2EDS GCC Altera toolchains up to version 10.3.

  • Added support for Intel FPGA - x86_64 MinGW32 GCC toolchains up to version 10.3.

  • Added support for CodeWarrior Development Studio for Microcontrollers Kinetis Freescale up to version 4.9.

Enhancements of support for already-supported toolchains (FSSCF):
  • Extended support for Microchip XC32 toolchains up to version 4.30.

  • Extended support for Microchip XC8 toolchains up to version 2.40.

  • Extended support for MSVC up to version 14.30.

  • Extended support for Keil C51 and CX51 compilers up to version 9.60.

  • Extended support for TI ARM compilers up to version 20.2.5. LTS.

  • Extended support for TI Arm Clang compilers up to version 1.3.1 LTS.

  • Extended support for TI C2000 compilers up to version 22.6.0 LTS.

  • Extended support for TI C6000 compilers up to version 8.3.12 LTS.

  • Extended support for TI MSP430 compilers up to version 21.6.0 LTS.

  • Extended support for GCC-based compilers up to version 12.

  • Improved support for Arm Keil MDK v5 toolchains with evaluation licenses.

  • Added support for the GCC pragma GCC system_header.

  • Added support for TASKING VX-Compilers for ARM up to version 6.3r1.

  • Added support for TASKING VX-Compilers for 8051 up to version 6.3r1.

  • Added support for TASKING VX-Compilers for PCP up to version 6.3r1.

  • Added support for Clang-based compilers up to version 16.

  • Improved support for GCC-based toolchains.

  • Improved support for Clang-based toolchains.

  • Improved support for the IAR toolchains.

  • Improved support for the MSVC toolchains.

  • Improved support for XC8-cc toolchains.

  • Improved support for the TASKING toolchains.

  • Improved support for the TI toolchains.

  • Improved support for MinGW-based toolchains.

  • Improved support for compilers based on sparc-rtems-gcc.

New integrations with IDEs, editors and, CI/CD systems:
  • Added plugin for NetBeans-based IDEs (including MPLAB X).

  • Added plugin for IntelliJ-based IDEs (including CLion).

  • Added integration with GitHub, including the support of Sarif outputs compatible with GitHub.

  • Added integration with GitLab, including the support of CodeClimate outputs compatible with GitLab and of GitLab authorization checking.

Enhancements to the integrations with IDEs, editors, and CI/CD systems:
  • Updated the Visual Studio plugin to support the most recent versions of the IDE.

  • Updated the Jenkins plugin to support the most recent versions of the “Analysis Model API Plugin” and “Warning Next Generation Plugin”.

Enhancements and additions to the ECLAIR User’s Manual:
  • Added new chapter on Service Classification and Prioritization.

  • Added new chapter on Adoption of Deviation Permits in ECLAIR.

  • Added new chapter on Requirements Management with ECLAIR.

  • Added new tables detailing undefined behaviors of the C programming language that are prevented by using ECLAIR MISRA C services: all versions of the C standard are covered.

  • Added new section on Running ECLAIR in Docker Containers to chapter Installation.

  • Added new section on Opening an ECLAIR Database to chapter Outputs.

  • Added new section on Integrating ECLAIR with Netbeans-Based IDEs to chapter Integrating ECLAIR with IDEs, Editors, and CI Tools.

  • Added new section on Integrating ECLAIR with IDEs based on the IntelliJ Platform to chapter Integrating ECLAIR with IDEs, Editors, and CI Tools.

  • Added new section on Integrating ECLAIR with Services for Software Development and Continuous Integration to chapter Integrating ECLAIR with IDEs, Editors, and CI Tools.

  • Added section on Running Pipelines Within a Docker Container to chapter Integrating ECLAIR with IDEs, Editors, and CI Tools.

  • Added paragraph on Running Pipelines Within a Docker Container to section Integrating ECLAIR with Jenkins.

  • Updated section Integrating ECLAIR with Visual Studio in chapter Integrating ECLAIR with IDEs, Editors, and CI Tools.

  • Expanded paragraph on Report Summary Pages in chapter Outputs to document the interactive reports chart.

  • Expanded section Integrating ECLAIR with Jenkins to consider a new plugin-free integration possibility.

  • The theme of the HTML version of the manual has been updated for increased readability.

  • Many examples have been added and many have been improved.

  • Added documentation for new commands and configurations.

  • Many other small improvements and corrections.

Enhancements and corrections to the ECLAIR GUI:
  • When setting an empty PATH in the Environment section of the GUI, the system PATH will be used instead of an empty one.

  • Added the possibility to configure the directory where the analysis results are stored.

  • Added the possibility to customize the help message for named settings.

  • The self-contained documentation in the ECLAIR GUI has been improved.

  • The documentation for ECLAIR_FULL_TXT has been corrected.

Enhancements to license-enforcing mechanisms:
  • Updated the protection mechanisms to Sentinel LDK 8.5.

Summary of Changes from Version 3.11.0 to Version 3.12.0

ECLAIR version 3.12.0 contains new features, many enhancements to existing features, and the correction of several defects.

New features:

  • New program eclair_format allows reformatting source code in compliance with most of the code layout guidelines of the BARR-C:2018 coding standard.

  • New “ECLAIR client kit” allows users of centralized ECLAIR analysis services to minimize the installed software base on their PCs.

New services:

  • Added a new service B.TROJANSOURCE that checks for vulnerabilities to Trojan source attacks.

  • Added a new service B.PREPCMNT that can be used to check that conditional inclusion preprocessor directives are closed with an #endif that is commented by the guard.

  • Added a new service B.STATINIT that can be used to check that static storage declarations have a complete initializer (this is useful when using compilers, such as TI’s TMS320C28x C/C++ compiler, that do not zero-initialize static and global variables).

  • Added a new service B.RECUMACR that can be used to check that a program does not contain recursive macro invocations.

  • Added a new service B.MACREXPR that can be used to complete the partial protection provided by MISRA guidelines about argument capture in macro body expansions.

  • Added a new service B.ECL to show unused ECL configurations.

Newly supported toolchains:

  • Added support for the Emscripten compiler toolchain to WebAssembly.

  • Added support for the xPack GNU RISC-V Embedded GCC toolchain.

  • Added support for the MPLAB XC8 C Compiler new driver xc8-cc.

Enhancements to existing services:

  • False positives have been fixed for the following services: MC2.1.1, MC2.9.1, MC2.19.4, MC2.19.7, MC3.R2.2, MC3R1.R2.2, MC3.D4.7, MC3R1.D4.7, MC3.D4.9, MC3R1.D4.9, MC3.R8.5, MC3R1.R8.5 MC3.R8.10, MC3R1.R8.10, MC3.R9.1, MC3R1.R9.1, MC3.R9.2, MC3R1.R9.2, MC3.R10.6, MC3R1.10.6, MC3.R10.7, MC3R1.R10.7, MC3.R10.8, MC3R1.10.8, MC3.R11.2, MC3R1.R11.2, MC3R1.R12.5, MC3.R13.3, MC3R1.R13.3, MC3.R14.2, MC3R1.R14.2, MC3.R17.4, MC3R1.R17.4, MC3.R17.8, MC3R1.17.8, MC3.R18.2, MC3.R18.8, MC3R1.R18.2, MC3.R18.3, MC3R1.R18.3, MC3.R18.6, MC3R1.R18.6, MC3R1.R18.8, MC3.R20.6, MC3R1.R20.6, MC3.R20.7, MC3R1.R20.7, MC3.R20.12, MC3R1.R20.12, MC3R1.R21.19, MC3.R22.5, MC3R1.R22.5, MC3R1.R22.10, MP1.0-1-8, MP1.0-1-9, MP1.3-2-4, MP1.5-0-17, MP1.7-3-5, MP1.8-5-1, MP1.12-8-2, MP1.15-3-4, MP1.16-2-2, NC3.3.1.e, NC3.3.1.m, NC3.3.3.b, NC3.3.4.b.

  • Fixed false negatives in the following services: MC3.D4.4, MC3R1.D4.4, SC1.PROG_003.

  • Fixed false positive and negatives in service SC1.PROG-038.

  • Where ECLAIR cannot be sure if the code is non-compliant, violation reports have been changed to caution reports and some messages have been improved for the following services: MC2.13.5, MC2.13.5L, MC2.17.2, MC3.R14.2, MC3R1.R14.2, MC3.R18.2, MC3R1.R18.2, MC3.R18.3, MC3R1.R18.3, MC3.R22.6, MC3R1.R22.6, MP1.5-0-17.

  • Fixed rare crashes caused by checks for the Clang and GCC error attribute in the following services: MC2.16.10, MC3.D4.7, MC3R1.D4.7, MC3R1.R22.10, MP1.0-3-2.

  • Fixed rare crashes in the following services: MC2.19.7, MC3.R8.9, MC3R1.R8.9, MP1.0-1-8 and MP1.0-2-1.

  • The MC3.D3.1 and MC3R1.D3.1 services have been improved: the configuration parameter requirement_set has an extra field to select the unit or program to be checked for requirements; all reporting is now for the whole project.

  • Service MP1.8-4-3 now avoids reporting the missing return statements in dead branches.

  • Service MC3.R16.1 now reports a violation when there are insufficient case clauses.

  • For services MC3.R7.4 and MC2R1.R7.4, caution reports are now output when the string literal is a function argument and there is no corresponding parameter declaration.

  • Defects have been fixed in the following ancillary services: STD.anonfild, STD.arayzero, STD.pteincmp, STD.ptruse, STD.strincmp, STD.stdtypes.

  • Reports for services MC3.R20.7 and MC3R1.R20.7 have been improved.

  • Reports for services MC2.2.4, MC3.D4.4, MP1.2-7-2, MP1.2-7-3 and NC3.2.1.c have been improved: redundant violations have been removed.

  • Reports for services MP1.0-1-1, MC3.R2.1 and MC2.14.1 have been improved: now do-while(0) constructs and parentheses are not reported as unreachable code.

  • Reports for services MC3.D4.9 and MC3R1.D4.9 have been improved: now they include the values of the function-like macro with their types.

  • Improved some analysis tables to reduce their size.

  • A few bugs in service B.EXPLAIN have been fixed and report messages have been improved.

  • Added new service configurations: MC3.R14.3, MC3R1.R14.3, MC3.R2.1 and MC3R1.R2.1

  • Improved the accuracy of services that require an analysis of potential side effects: MC2.12.13, MC2.12.2, MC2.12.3, MC2.12.4, MC2.13.5L, MC2.13.5, MC2.14.10, MC2.14.1, MC2.14.2, MC2.19.7, MC2.8.9, MC3.D4.9, MC3.R13.1, MC3.R13.2, MC3.R13.3, MC3.R13.5, MC3.R13.6, MC3.R14.2, MC3.R15.7, MC3.R2.1, MC3.R2.2, MC3.R2.3, MC3.R2.4, MC3.R8.6, MP1.0-1-10, MP1.0-1-1, MP1.0-1-3, MP1.0-1 -5, MP1.0-1-8, MP1.0-1-9, MP1.15-3-4, MP1.16-0-4, MP1.3-2-4, MP1.5-0-1, MP1.5-2-10, MP1.5-3-4, MP1.6-4-2, MP1.6-5-1, MP1.6-5-2, MP1.6-5-4, MP1.6-5-5, MP1.6-5-6, MP1.8-3-1, NC3.6.3.a, NC3.8.2.d.

  • All services now follow the convention used in GCC to refer to local classes and lambda functions.

  • A new global configuration parameter tool_tag has been added. The configuration parameter compilers has been modified to accept a list of tool tags; tools with the same tag are taken to be compatible. Note that compilers is an optional configuration parameter for users of: MC2.1.3, MC3.D1.1, MC3R1.D1.1, MP1.1-0-2.

  • Report tags have been added or replaced hide/show tags for some configuration parameters: MC2.19.2, MC2.19.3, MC3.R20.2, MC3.R20.3, MC3R1.R20.2, MC3R1.R20.3, MP1.16-2-4, MP1.16-2-5, MP1.16-2-6, NC3.2.2.b, NC3.2.2.d, NC3.2.2.h, NC3.4.3.b, NC3.4.3.d, NC3.4.3.f, NC3.7.2.c, NC3.8.4.d.

  • Implementation of MC2.19.4, MC3.R20.4 and MC3R1.R20.4 have been improved to check all floating-point literals.

  • The POSIX library can be included as a standard library using a new global configuration parameter stdlib. ECLAIR now supports:

    • the checking for reuse of the identifiers provided by POSIX (services MC2.20.1, MC2.20.2, MC3.R21.1, MC3R1.R21.1, MC3.R21.2, MC3R1.R21.22, MP1.17-0-1, MP1.17-0-2, MP1.17-0-3);

    • the checking of the use of errno just before and following calls to POSIX functions and macros that can modify errno (services MC3R1.R22.9, MC3R1.R22.10);

    • ensuring that there are adequate checks for error values that may be returned by calls to POSIX functions (services MC2.16.10, MC3.D4.7, MC3R1.D4.7 and MP1.0-3-2).

  • For the behavior configurations for the used C/C++ implementation, a warning is now given if a behavior for a tool is specified multiple times. The syntax of these configurations has also been improved and simplified.

  • Improved the etypes and terminals report taggers.

  • Added new selector for calls, contexts, statements, and types that allow to differentiate the matching depending on the language or standard.

  • Added new condition line(LIN_RANGE) to matcher loc that allows selecting locations by line number range.

  • Improved comment-based tagging. The end label of a tagging comment should now always be prefixed by : to permit a more robust syntax checking. Multiline tagging comments are now accepted.

  • The user can now set ECLAIR attributes for types and declarations directly in the source code.

  • Fixed a performance bug in macro name extraction from a macro_selector.

Enhancements to the ECLAIR User’s Manual:

  • The relationship between MC3.R1.1 and MC3.R1.2 (similarly, MC3R1.R1.1 and MC3R1.R1.2) has been clarified and examples have been added.

  • References in the documentation for some MC3A1 and MC3R1 services have been corrected.

  • Added section on “AUTOSAR C Implementation Rules Coverage.”

  • SiFive Freedom Studio has been added to the list of supported IDEs and instructions for the installation of the ECLAIR Eclipse plugin on it have been added.

Enhancements of support for already-supported toolchains:

  • Support for the IAR toolchains has been improved.

  • Support for the ARM/Keil toolchains has been improved: this affects both ARM Compiler 6 (a.k.a. armclang) and ARM Compiler 5 (a.k.a. armcc).

  • Support for the Microsoft Visual C++ toolchain has been improved.

  • Support for the GCC-based toolchains has been improved.

  • Support for the QNX SDP toolchain has been extended to the latest versions.

Enhancements to the ECLAIR GUI:

  • Now it is possible to create multiple build, analysis, and reporting configurations that can subsequently be referred in the Configurations steps.

  • Improved the documentation accessible via the ? buttons.

Enhancements to detailed outputs:

  • A chart for quick visualization of report counts has been added.

  • Selections can now be exported or shared with a link.

  • The selection and sorting of rows and columns for the reports count is now supported.

  • Added a new feature that allows excluding or including reports that match the currently selected text.

  • The commands starting with -report_counts1_ and with -report_counts2_ have been uniformed and they now start with the prefix -report_counts_.

  • The memory consumption of eclair_report and of browsers visualizing detailed outputs has been reduced.

  • Tags applied to a report are now visible in all report kinds. This required a change in the .ecd file format: old .ecd files are thus no longer compatible and should be regenerated from the corresponding .ecb files using the new version of ECLAIR.

  • Rich outputs in HTML, ODT, DOC, XML and pure text format can now be generated with all license coverages (partial and SME), although with different precision in the localization of the involved code locations and corresponding messages: line/column numbers and messages are (as always) only available to SME coverage licensees.

  • Fixed a bug in the Import action feature of the ECLAIR report view.

Enhancements to summary outputs:

  • Added a new by_tag.txt file with tags information to the outputs produced with -summary_txt.

  • The integrated filter mechanism now allows to enable and disable items separately by simple clicking on them.

  • Improved the generation of the FCA 7-Z0072 reports.

Enhancements to the integration with IDEs and editors:

  • The report displayed in the IDE/editor is now also highlighted in the ECLAIR detailed reports page.

  • The eclair_report -auto_shutdown options has been improved: now it no longer stops eclair_report if a client is connected.

  • Improved the logging of all the plugins.

  • Improved positioning in the integration for Visual Studio.

  • Fixed possible eclair_report crash during client connection.

Enhancements to installers:

  • The same installers can now be used independently from the licensed packages, from the license coverage, and from the license-enforcing mechanism.

  • The installation log files generated by Windows installers are now written in UTF-8.

  • The installation log files generated by all (Windows, Linux and OS X) installers are now terminated with a line reporting the system time at completion of the installation process.

Enhancements to license-enforcing mechanisms:

  • Updated the protection mechanisms to Sentinel LDK 8.2.1.

  • Clone-detection has been improved especially for users planning to deploy ECLAIR in Docker or LXC containers.

  • The eclair_licman program is now more general and can be used to work with ECLAIR license keys of any kind; consequently, both the options -d (express detach) and -c (express cancel detach) now take the product numeric id as a mandatory argument.

Summary of Changes from Version 3.10.0 to Version 3.11.0

ECLAIR version 3.11.0 contains several new features, lots of enhancements to existing features, and some bug fixes.

Enhancements to eclair_report:

  • Added the possibility to run an external script directly from the eclair_report interface. The script can be triggered from either browser, GUI or IDE and can perform every type of action exploiting the information of the selected report(s).

  • Added an -auto_shutdown option that allows to turn off eclair_report automatically after a set period of time from when all GUI or browser tabs are closed.

  • The magnifying glass icon next to a report will now save a screenshot of the source code area interested by it in the clipboard.

  • Added options -summary_doc and -full_doc to produce summary outputs in DOC format.

  • Renamed option -metrics_txt.

Enhancements to toolchains support:

  • Added support for the CrossWorks toolchain for ARM: this supports the GCC/cc1 compilation tools, the LLVM/Clang compilation tools, as well as the native (cc) compiler driver.

Enhancements to Linux integration:

  • The Linux installer will add eclair_report and eclair_gui to the application list of the desktop environment.

  • The Linux installer will create an association between the .ecs files and eclair_gui.

  • The Linux installer will create an association between the .ecd files and eclair_report.

Enhancements to the GUI and integration with external IDEs and CI systems:

  • A Visual Studio plugin has been added.

  • Several help-messages in the ECLAIR GUI have been improved and extended with more information.

  • The ECLAIR GUI and all the integration plugins now allow specifying eclair_report server options.

  • Improved loading/saving of .ecs files.

  • Improved support for Windows UNC paths.

  • The interface with Jenkins has been improved in several respects:

    • support for Jenkins pipelines has been added;

    • added ECLAIR Project Home in the left panel of the build view, which links to the eclair_report homepage of the reports database generated by the selected build.

  • The selection of reports has been further improved.

Enhancements to existing services:

  • Analysis speed and memory consumption has been generally improved.

  • The helpers that collect the effects of source code components have been improved; these changes are relevant to:

    • the added MISRA C++ services MP1.0-1-8 and MP1.15-3-4, and

    • other existing services that rely on a knowledge of the effects.

  • False positives have been fixed in the following services: MC3A1.R21.19, MC3R1.R21.19, MC3.R14.3, MC3.R14.3, MC3R1.R14.3, MC3.R18.6, MC3R1.R18.6, MC3.R9.1, MC3R1.R9.1, MC3.R8.5, MC3R1.R8.5, MC3.R5.7, MC3R1.R5.7, MP1.0-1-2, MP1.3-3-1, MP1.2-10-3, MP1.7-5-2.

  • Support for MC3.R3.1 and MC3R1.R3.1 has been improved.

  • The report locations for MC3A1.R21.18 and MC3R1.R21.18 have been improved.

  • A bug leading to wrong report suppression has been fixed.

  • Reports concerning recursive function have improved messages.

  • A new global configuration extra_definitions has been added that allows the user to add information about defined entities when the analyzed source code is incomplete.

  • Improved non-ASCII characters handling.

  • Reimplemented MP1.0-1-12 to better match the rule’s source description.

  • Reimplemented NC3.5.3.c.

Enhancements to documentation:

  • The ECLAIR User’s Manual has been improved and integrated in several aspects:

    • A GEP (Guideline Enforcement Plan) for MISRA C++:2008 has been added;

    • Chapter Custom Get and Run actions in ECLAIR has been added;

    • a list of suggested tagging systems has been added in The Report Tagging System Section;

    • the of Common Features for all the HTML output pages has been improved and completed;

    • all the sections about the integration with IDEs and editors have been revised and updated;

    • the sections about Jenkins integration have been revised and updated;

    • Section Producing DOC Outputs about the generation of outputs in DOC format has been added;

    • Section Producing ODT Outputs about the generation of outputs in ODT format has been extended and improved.

    • Section Metrics Output to Spreadsheet Programs about the generation of spreadsheet files containing the program metrics has been updated.

New services:

  • Services MP1.14-8-1, MP1.14-5-1, MP1.14-6-1, MP1.12-1-1, MP1.0-1-8, MP1.7-4-2 and MP1.15-3-4 for checking compliance with the corresponding MISRA guidelines for C++ have been added.

  • A new metric B.LINES_FILE that counts the number of physical lines in a file has been added and the services MET.B.LINES_FILE and EMET.B.LINES_FILE have been added to the MET and EMET rule sets, respectively.

Summary of Changes from Version 3.9.0 to Version 3.10.0

ECLAIR version 3.10.0 contains several enhancements, some new features, and bug fixes.

Enhancements to detailed outputs:

  • The first table in the Overall Information page shows the static selection and variant, if any, that have been used to produce the reports.

  • The ECLAIR selection panel switch is now visualized in red when the current dynamic selection (i.e., the one operated via the panel itself) is hiding reports.

  • The ECLAIR selection panel now supports message-based selection with regular expressions; this allows working more effectively on projects with many violations.

  • The ECLAIR selection panel now allows to save and load named selections.

  • The summary pages (showing reports counts by service, by first file or by service and first file) now begin with a row containing the totals for each column; such total numbers reflect the current selection (the static one as further refined by the dynamic one, if any).

Enhancements to the GUI and integration with external IDEs and CI systems:

  • Added a File Manipulator setting to the Toolchain Components page of the GUI.

  • The interface with all supported IDEs has been improved: now IDEs can connect to a remote ECLAIR report server.

  • Support for multi-IDE access to an ECLAIR report server has been added: now IDEs from different computers can be connected to the same ECLAIR report server at the same time.

  • The ECLAIR report server has been improved in several respects:

    • HTTPS support has been added (the -ssl option, if present, specifies that the server must run in HTTPS mode; the -ssl_certificate option specifies the path for a PEM certificate for the ECLAIR report server when run in HTTPS mode).

    • Stability and security have been significantly improved (the -actions option specifies whether remote users can perform stop, changing and changed actions on the ECLAIR report server).

    • Logging has been improved.

    • Support for Jenkins and HTPASSWD authorizations have been added (the -auth option specifies which database paths are/aren’t accessible and which need Jenkins or HTPASSWD authentication).

    • Pairing mechanisms have been added to associate browsers with an IDE (the eclair_report server host option specifies the ECLAIR report server hostname/IP address to connect to); the Use local ECLAIR report server as a proxy option specifies whether the remote server is running without a site license and therefore requires a local eclair_report proxy).

  • The interface with Jenkins has been improved in several respects:

    • HTTPS support has been added (the Use ECLAIR SSL mode option specifies whether the ECLAIR report server needs to be launched or is already running in HTTPS mode; the ECLAIR SSL certificate path option specifies the location of the certificate to be used when starting the ECLAIR report server).

    • Efficiency has been considerably improved.

    • The ECLAIR report server stability has been improved under Jenkins (the ECLAIR server ownership option specifies whether the ECLAIR report server is managed by Jenkins).

    • Jenkins logging for the ECLAIR report server has been added.

Enhancements to existing services:

  • Several services for checking compliance with the MISRA C and C++ guidelines have been improved, false positives have been corrected, and messages have been clarified.

  • False negatives of the service for checking compliance with MISRA C:2012 Rule 22.6 (concerning pointers to FILE not to be used after the associated stream has been closed) have been corrected.

  • Several services for checking compliance with the BARR-C:2012 guidelines have been improved as well.

  • False negatives for checking compliance with the BARR-C:2012 Rule 1.5.b when no file was specified by the configuration has been fixed and a caution report is shown if the named file is empty.

  • Service B.PTRUSE that checks for redundant casts has been improved and false positives fixed.

  • Failure when using B.EXPLAIN has been fixed and reports improved.

  • All services concerned with tagging and checking tools in the toolchain will now use the canonical pathname. Note that this may require a change to configuration values that select a tool; for instance, when the value is a regular expression matching a tool name, it will need to be modified to match the tool’s canonical pathname.

Enhancements to toolchain support:

  • Support for the Renesas RX toolchain has been improved.

  • Support for the GNU toolchains and all their variants has been improved.

Enhancements to documentation:

  • The ECLAIR User’s Manual has been integrated and improved.

New services:

  • Services MP1.0-1-2 and MP1.0-1-6 for checking compliance with the corresponding MISRA guidelines for C++ have been added.

  • Service B.REDCAST that checks for redundant casts has been added.

Summary of Changes from Version 3.8.1 to Version 3.9.0

ECLAIR version 3.9.0 contains several enhancements and some bug fixes.

  • A brand new, very effective Jenkins plugin has been added.

  • ECLAIR now provides support for 100% of the guidelines in MISRA C:2012 Revision 1 with Amendment 2.

  • New service B.PROJORG allows checking the project organization and internal dependencies as well as detecting unwanted interference between project components.

  • Support for all MISRA standards has been improved further.

  • Support for BARR-C:2018 has been improved.

  • The models of GNU and derived toolchains have been improved.

  • The models of IAR toolchains have been improved.

  • The ECLAIR GUI has been improved.

  • The ECLAIR workspace default directory has been changed so as to be tied to the particular ECLAIR version; this facilitates users that need to run different versions of ECLAIR.

  • All documentation has been extended and improved.

  • Analysis efficiency has been improved.

  • The ECLAIR Bug Finder messages have been improved.

  • A defect causing crashes in some rare circumstances has been fixed.

  • Sentinel LDK has been updated to the latest version published by Thales, which solves several issues and contains numerous improvements. All user are recommended to upgrade and not skip the installation of Sentinel LDK RTE when/if proposed by the ECLAIR 3.9.0 installer.

Summary of Changes from Version 3.8.0 to Version 3.8.1

ECLAIR version 3.8.1 contains only minor fixes and documentation improvements.

  • The model of ARM Compiler 5 (armcc) has been improved.

  • Defects in the use of the ancillary services have been fixed.

  • The computation of metric HIS.COMF did not correctly account for header files and this has been corrected.

  • For services concerned with entity name checking, the short circuit tagger for selecting the entity name now matches both the entity and its name before the associated report tag is assigned.

  • STM32CubeIDE and Silicon Labs Simplicity Studio have been added to the list of supported IDEs and instructions for the installation of the ECLAIR Eclipse plugin on them have been added to the manual.

  • IDE integration has been improved to support old versions of Eclipse.

  • The manual has been improved.

Summary of Changes from Version 3.7.0 to Version 3.8.0

ECLAIR version 3.8.0 contains numerous enhancements and some bug fixes.

  • Support for MISRA C:2012 Amendment 2 has been added: this allows coding MISRA C compliant projects using any version of the ISO C language standard.

  • Brand new integration technology with Eclipse, Visual Studio Code and Emacs has been added: these features are now available across all ECLAIR licensing schemes.

  • ECLAIR support for HIS and non-HIS metrics has been completely reviewed: a total of 48 function, translation unit, and program metrics are now available and qualifiable also in the context of critical development.

  • Support for all guidelines concerned with the C/C++ implementation, unspecified and undefined behaviors has been improved. Note that this includes changes to the behavior configuration parameters provided by the ancillary services.

  • Support for the BARR-C:2018 coding standard has been further extended and improved. In particular:

    • rules concerning the spacing and alignment of code have been improved;

    • rules concerning the use of identifiers reserved for the standard library have been revised to match the BARR-C source description and avoid false positives.

  • Support for several MISRA C/C++ guidelines has been improved.

  • ECLAIR User’s Guide has been improved. In particular:

    • clickable references to the official coding standard documents have been added so that when the appropriate PDF files are installed in ECLAIR, the document is opened at the right page;

    • a chapter describing the installation and use of the new integration technology (see above) has been added;

    • the section about checking the project vocabulary has been clarified.

  • Support for toolchains has been improved. In particular:

    • support for the ESP-IDF and the IAR MSP430 toolchains has been added;

    • support for other IAR toolchains and the CodeWarrior HC12 toolchain has been improved.

  • A GUI glitch whereby garbled text was sometimes displayed in the run log area has been fixed.

  • All ECLAIR executables in the Windows version are now digitally signed by BUGSENG with an extended validation (EV) code-signing certificate issued by Sectigo (formerly Comodo), a Microsoft partner enrolled and authorized for Kernel Mode Code Signing as part of the Microsoft Trusted Root Certificate Program. In previous versions only the installers and uninstallers were digitally signed.

Summary of Changes from Version 3.6.3 to Version 3.7.0

ECLAIR version 3.7.0 contains numerous enhancements and some bug fixes.

  • Support for the BARR-C:2018 coding standard [8] has been extended and improved. This version of ECLAIR covers, under the prefix NC3, more than 80% of the guidelines.

  • Support for MISRA C:2012 rule 22.3 (see [45] and [51]) has been added.

  • Support has been added to the GUI for computing metrics and consulting the results.

  • The HTML reporting facility has been enhanced to allow easier selection of what should be shown; the documentation in the manual for this has been updated and improved.

  • New rule sets MET for metric reporting and EMET for exceeded metric reporting have been added.

  • Sentinel LDK has been updated to the latest version published by Thales, which solves certain important security issues of Sentinel LDK itself. All user are recommended to upgrade and not skip the installation of Sentinel LDK RTE when/if proposed by the ECLAIR 3.7.0 installer.

  • Checkers concerned with encapsulating and documenting asm statements, have been improved, so that false positives are avoided. Also we have added two configuration parameters whereby the user can select if they wish to allow or disallow an encapsulating macro or function to include both encapsulated asm statements mixed with unencapsulated asm statements.

  • For checkers whose results depend on the, possibly approximate, evaluation of a numeric value, because of an improved evaluation procedure, the number of caution reports have been reduced: both by removing any caution reports that are now known to be false and by upgrading other caution reports to a violation that are now known to be true.

  • Checkers reporting the inclusion of increment-decrement operators in expressions with other potential side effects were falsely reporting the operators when applied to volatile objects. This is now fixed.

  • Checkers concerned with reporting invariant Boolean expressions have been improved so that they are not reported when in a constant context.

  • When showing the include paths, the file locations in the reports depended non-deterministically on the selected paths. Such nondeterminism is now avoided.

  • Crash that occurred when analyzing some preprocessor conditional expressions has been fixed.

  • Report tagging has been changed to allow for the assignment of multiple tags.

  • Keil armcc model now recognizes the inline keyword in C99 mode.

Summary of Changes from Version 3.6.2 to Version 3.6.3

ECLAIR version 3.6.3 contains only minor fixes and documentation improvements.

  • Support for the Wind River DIAB and the Freescale HC12 toolchains has been improved.

  • A chapter about troubleshooting has been added to the manual.

Summary of Changes from Version 3.6.1 to Version 3.6.2

ECLAIR version 3.6.2 contains only minor fixes and documentation improvements.

  • The model of the IAR compiler for ARM has been improved.

  • A glitch in the GUI has been fixed that caused some unwanted scrolls when zoom was applied.

  • A glitch in some goto-related metrics related to indirect gotos has been fixed.

  • The manual formatting and content has been improved.

Summary of Changes from Version 3.6.0 to Version 3.6.1

ECLAIR version 3.6.1 contains only bug fixes and documentation improvements.

  • The manual formatting and content has been improved.

Summary of Changes from Version 3.5 to Version 3.6.0

ECLAIR version 3.6.0 contains numerous enhancements and some bug fixes.

  • Support has been added for MISRA C:2012 Third edition, first revision [51]. Note that this comprises:

    These new guidelines are available under the prefix MC3R1, while the guidelines for MISRA C:2012 [45] and MISRA C:2012 Amendment 1 [46] remain available under the prefixes MC3 and MC3A1, respectively.

  • Support has been added for the BARR-C:2018 coding standard [8]. This support covers more than 75% of the guidelines which are available under the prefix NC3.

  • the configuration parameter user_entity_name, provided for checkers concerned with the syntax of entity names, that specified the allowed format and vocabulary for the entity and macro identifiers, has been split into two and improved.

  • Due to bug fixes, recently noted false negatives are now reported, in particular:

    • for checkers concerned with the initialization of automatic variables;

    • in the checking of undefined and unspecified behavior

    • for checkers that require knowledge about the expected behavior of calls to standard library functions and the variables passed as arguments;

    • for checkers requiring pointee types to be declared const whenever possible;

    • when checking for guards in empty header files.

  • Due to improvements to the checkers and associated tools, the number of false positives has been reduced:

    • for checkers concerned with the initialization of automatic variables;

    • for checkers concerned with functions that return error values and with ensuring the returned value is checked;

    • for checkers concerned with functions that may return the end-of-file indicator EOF and with ensuring the return value is checked;

    • for checkers concerned with standard library functions that provide error information using errno;

    • for checkers that require knowledge about the expected behavior of calls to standard library functions and the variables passed as arguments;

    • for checkers concerned with missing return statements that were wrongly reporting asm statements;

    • for MC2.20.2 and the false reporting of the use of structure names reserved by the standard library;

    • for checkers detecting commented-out code;

    • for checkers concerned with detecting recursive method calls.

    • for checkers concerned with casts removing const or volatile qualification from the type of a pointer or reference.

    • for checkers that report unnecessary use of external linkage

  • Due to improvements to the checkers and associated tools, the number of false caution reports has been reduced and some true caution reports have been converted to violation reports:

    • for checkers concerned with the initialization of automatic variables;

    • for checkers concerned with reporting recursive functions when the function call is indirect or the callee is virtual.

  • Due to improvements to the checkers and associated tools, the report messages have been improved.

  • For checkers when the report concerns an entity and not a specific declaration of the entity, we have added a configuration parameter whereby the user can select if all declarations for that entity should be shown or just a single representative.

Summary of Changes from Version 3.4 to Version 3.5

ECLAIR version 3.5 contains, besides numerous enhancements to all parts of the system, major efficiency improvements: memory consumption has been cut to half and analysis speed has been doubled or more, without any impact on analysis precision (speedups up to 6x have been observed).

Summary of Changes from Version 3.3 to Version 3.4

ECLAIR version 3.4 contains a new web application for viewing reports, several new and revised services and improvements to all aspects of the system.

New services include support for an appreciable part of the BARR-C:2018 coding standard [8]. This replaces ECLAIR support for the previous version [7].

There is a brand new innovative HTML reporting tool providing clear visualization with versatile navigation facilities of all the information concerning an ECLAIR analysis. With this new reporting tool the user has quick access to:

  • information about the build process and the ECLAIR analyses performed;

  • statistics on the various findings;

  • detailed reports about each finding;

  • optionally, full project sources, both before and after preprocessing.

The HTML outputs are compatible with most popular browsers, such as Google Chrome, Internet Explorer, Mozilla Firefox, Safari and Opera.

The configuration language, ECL, has also further improved and simplified. While ECLAIR 3.4 is mostly backward compatible with ECLAIR 3.3, the syntax of some configuration options has changed. As usual, to facilitate users in the transition, BUGSENG provides a free update service: let us have your old configuration files and we will send the new ones to you.

Summary of Changes from Version 3.2 to Version 3.3

ECLAIR version 3.3 contains substantial new functionality over the previous versions and offers significant improvements in all aspects of the system. Most notably:

  • there is a brand new GUI that makes it very simple to configure a project for static analysis with ECLAIR;

  • a new service, called B.EXPLAIN, outputs a natural language description for each ECLAIR configuration in force;

  • configuration templates are provided for global configurations and for each supported service (e.g., coding rule checkers);

  • reports suitable for printing can now be generated in the OpenDocument Text format (which can be easily turned into, e.g., PDF);

  • the suppression mechanisms allow more fine-grained control, which is very useful when dealing with all the not-completely-defined behaviors of C and C++.

The configuration language, ECL, has also further improved and simplified. While ECLAIR 3.3 is mostly backward compatible with ECLAIR 3.2, the syntax of some configuration options has changed. As usual, to facilitate users in the transition, BUGSENG provides a free update service: let us have your old configuration files and we will send the new ones to you.

Summary of Changes from Version 3.1 to Version 3.2

ECLAIR version 3.2 contains many new static analyses, especially targeted at security. Support has been improved and extended for C11, C++11, C++14 and C++1z. The quality of ECLAIR reports has been improved further and their generation has been sped up by more than an order of magnitude.

There are new, very convenient installers both for the Windows and the Linux versions.

The configuration language, ECL, has also been significantly improved and simplified. While ECLAIR 3.2 is mostly backward compatible with ECLAIR 3.1, the syntax of some configuration options has changed. As usual, to facilitate users in the transition, BUGSENG provides a free update service: let us have your old configuration files and we will send the new ones to you.

Summary of Changes from Version 3.0 to Version 3.1

ECLAIR version 3.1 contains significant improvements in the checking of underlying/essential types required by the MISRA coding standards. More generally, the messages in ECLAIR reports have been uniformed and improved.

ECLAIR version 3.1 has improved support for Windows 8.* and Windows 10.

Summary of Changes from Version 2.3 to Version 3.0

ECLAIR version 3.0 contains many new services and major improvements to existing services, most notably those supporting the MISRA C:2012 coding standard [45].

Configurability has also been enhanced and makes it easier to support projects that use C and C++ at the same time and/or use different coding standards on different parts of the project. Deviation mechanisms have also been extended and improved.

New services include the exceedingly useful B.OBJCMP, which allows users to guarantee their changes to make the code compliant do not modify the generated object code (which implies no new bug has been introduced). And B.REMAKE, which automatically builds makefiles that can reproduce a build (and the analysis) at maximum parallelism, even if the project build system does not support parallel builds.

While ECLAIR 3.0 is mostly backward compatible with ECLAIR 2.*, the syntax of some configuration options has changed. As usual, to facilitate users in the transition, BUGSENG provides a free update service: let us have your old configuration files and we will send the new ones to you.

Summary of Changes from Version 2.1 to Version 2.3

The environment variables used to specify the toolchain components to be intercepted have been made uniform between the Windows and the Linux versions of ECLAIR. The following table gives the correspondence between the environment variables for which support has been dropped and those that have taken their place:

ECLAIR 2.1

ECLAIR 2.3

MS_LINK

LD

MS_CL

CC

MS_LIB

AR

CL_ALIASES

CC_ALIASES

LINK_ALIASES

LD_ALIASES

LIB_ALIASES

AR_ALIASES

Summary of Changes from Version 1.2

ECLAIR version 2.* contains major improvements and radical changes in every part of the system. As a consequence, as is often the case for major versions, there is no backward compatibility with respect to ECLAIR version 1.2, the previous released version. In particular, the syntax of many configuration options changed and configuration files for ECLAIR version 1.2 cannot be expected to work with ECLAIR version 2.*. To facilitate users in the transition, BUGSENG provides a free update service: let us have your old configuration files and we will send the new ones to you.

Installation

This chapter describes the hardware/software requirements and the software installation procedures that are applicable to version 3.14.0 of ECLAIR.

Please note that these are purely technical requirements and procedures. See your ECLAIR license for additional requirements.

Hardware Requirements

The machines on which ECLAIR will be run must be equipped with enough CPU cores, RAM memory and hard disk storage to meet the user expectations. Please note that, since this version of ECLAIR is free from artificial limitations concerning the size and complexity of the source files and of the entire project, there is no amount of resources that can be generally declared as sufficient.

That being said, it can be safely assumed that no serious verification work can take place on a machine where less than 8 GB of RAM or less than 32 GB of hard disk storage is available to ECLAIR.

Software Requirements

The version of ECLAIR shipped along with this manual has been tested on the following supported operating systems: Windows 8/x86_64, Windows 8.1/x86_64, Windows 10/x86_64, Windows 11/x86_64, macOS 12, Ubuntu 20.04/x86_64, Ubuntu 22.04/x86_64, Ubuntu 24.04/x86_64, AlmaLinux OS 9/x86_64, Debian 10/x86_64, Debian 11/x86_64, Debian 12/x86_64, CentOS 8/x86_64, CentOS Stream 9/x86_64.

The latest service packs and security updates must be installed.

This version of ECLAIR is also expected to work on the following non-supported operating systems: Windows XP/i686, Windows 7/i686, Windows 7/x86_64, macOS 11, Ubuntu 16.04/x86_64, Ubuntu 18.04/x86_64, Ubuntu 18.10/x86_64, Ubuntu 19.04/x86_64, Ubuntu 19.10/x86_64, Ubuntu 20.10/x86_64, Ubuntu 21.04/x86_64, Ubuntu 21.10/x86_64, Ubuntu 22.10/x86_64, Ubuntu 23.04/x86_64, Ubuntu 23.10/x86_64, Debian 8/i686, Debian 8/x86_64, Debian 9/x86_64, CentOS 7/i686, CentOS 7/x86_64, Fedora 25/x86_64, …, Fedora 40/x86_64, RHEL 6.7/i686, RHEL 6.7/x86_64, RHEL 7.2/i686, RHEL 7.2/x86_64, RHEL 7.3/x86_64, RHEL 7.4/x86_64, RHEL 7.5/x86_64, RHEL 7.6/x86_64, RHEL 7.7/x86_64, RHEL 8.1/x86_64, RHEL 8.2/x86_64, RHEL 8.3/x86_64, RHEL 8.4/x86_64, RHEL 8.5/x86_64, RHEL 9/x86_64, openSUSE Leap 42.1/x86_64, openSUSE Leap 42.2/x86_64, openSUSE Leap 42.3/x86_64, openSUSE Leap 15.0/x86_64, openSUSE Leap 15.1/x86_64, openSUSE Leap 15.2/x86_64, openSUSE Leap 15.3/x86_64, openSUSE Leap 15.4/x86_64, openSUSE Leap 15.5/x86_64.

The version of ECLAIR shipped along with this manual is protected using Thales (formerly Gemalto, formerly SafeNet) Sentinel LDK: see below for the system-dependent instructions on how to install Sentinel LDK’s run-time environment.

Interactive ECLAIR analysis HTML outputs and the Sentinel Admin Control Center require a modern web browser. The following browsers are recommended, in decreasing order of preference:

  • Google Chrome, latest version;

  • Mozilla Firefox, latest version;

  • Safari, latest version;

  • Microsoft Edge.

Installation on a Windows Platform

The supported installation procedures for a Microsoft Windows operating system are as follows.

Installation and Uninstallation with the Windows Installer Program

For ordinary users, the most convenient way to install ECLAIR on a Windows platform is via the installer. The ECLAIR Windows installers and uninstallers can be used both interactively and in silent mode from the command line: we will cover both uses in the next sections.

Installation with the Windows Installer

Whether you choose to use the interactive or the silent installation modes, it is important that you ensure no ECLAIR components are running before starting installation: if in doubt, restart the machine.

It is also strongly recommended that you temporarily disable all anti-malware scanners. The reason is that they can easily interfere with the installation process and can manipulate the installed files in a way that may cause malfunctions. Note that ECLAIR installers as well as all the installed ECLAIR executables are digitally signed by BUGSENG with an extended validation (EV) code-signing certificate issued by Sectigo (formerly Comodo), a Microsoft partner enrolled and authorized for Kernel Mode Code Signing as part of the Microsoft Trusted Root Certificate Program.

Warning

Do not forget to re-enable anti-malware scanners at the end of installation

This is really important: while ECLAIR and its installers are malware-free (besides other obvious considerations, the executables are generated on non-Windows environments that are completely immune to viruses), not re-enabling anti-malware scanners after installation will leave you unprotected.

Interactive Mode

The ECLAIR Windows installers can be used both by Administrator accounts and by accounts configured as Standard user. If installing ECLAIR as a standard user, make sure that the right version of the Sentinel LDK Run-Time Environment has already been installed on the machine because standard users are not able to install it.

Warning

Sentinel LDK RTE is a strong prerequisite

Do not use the ECLAIR Windows installers from a standard user account unless you know that the installer has already been run by an administrator account on the same machine and installation of Sentinel LDK RTE was not skipped.

When the installer starts, it welcomes you with a window like the following:

_images/Windows_Welcome.png

There you can see the ECLAIR version (3.14.0 in this example), the maximal combination of packages the platform may be instantiated upon (MCP), the architecture (w64, for Windows/x86_64), and a license-kind identifier (P in this example, from Professional, as opposed to Trial or Educational).

If the installer detects that the very same release of ECLAIR is already installed on the machine, it will display the following instead of the welcome page:

_images/Windows_Already_Installed.png

If you click the OK button, the previous version will be automatically removed and installation will start.

From the welcome page, clicking on the Next button will bring you to the license agreement page:

_images/Windows_License_Agreement.png

Scroll down through the license and, if you agree to its terms, click on the I Agree button. What you will see then is the component selection page, whose appearance depends on whether you are using the installer from an administrator account or from a standard account. In the first case you will see

_images/Windows_Choose_Components_Admin.png

while, in the second case, the Sentinel LDK RTE component cannot be selected.

_images/Windows_Choose_Components_Ordinary.png

If and only if you are running the installer from an administrator account, will you then be brought to a page like the following:

_images/Windows_Choose_Users.png

Here you have the option to install ECLAIR for just your user account or for any user account on the computer.

When installing for your user account only, the proposed install location is within your space, e.g.:

_images/Windows_Choose_Install_Location_Ordinary.png

Otherwise, the proposed location is a system location, e.g.:

_images/Windows_Choose_Install_Location_Admin.png

In any case, you can change the proposed locations, as well as the Start Menu folder for shortcuts:

_images/Windows_Choose_Start_Menu_Folder.png

If you are running the installer from an administrator account you will be notified once the installation of Sentinel RTE is successfully completed.

_images/Windows_Install_Sentinel.png

If you click on the Yes button, the installer for Sentinel LDK RTE will be launched. Note that, in case Sentinel LDK RTE was already installed on the computer, you will be presented with the choice to Repair or Remove the installation: choose the former.

If you had Fingerprint generation checked in the component selection page, you will now be offered the following:

_images/Windows_Collect_Fingerprint.png

Click on Yes if you need a node-locked protection key (as opposed to using a dongle protection key or floating network licenses), in which case you will see

_images/Windows_Fingerprint_Collected.png

In either case, you will then be able to update the PATH environment variable:

_images/Windows_Update_Path_Admin.png

You should normally click on Yes, unless you wish to manually update PATH in the registry or you commit to ensuring the variable is appropriately set before running any ECLAIR component.

At this stage you will be presented with the location where the installation log has been saved:

_images/Windows_Installation_Log.png

At the end of the installation process you will see this page, where a clickable link to the ECLAIR User’s Manual is given for your convenience:

_images/Windows_Completing.png
Silent Mode

The installers can also be run in non-interactive, silent mode from the command line. When used in this mode, the installers:

  • will not install prerequisites;

  • will not collect fingerprints;

  • will update the PATH environment variable;

  • will not generate an installation log.

In order to run the installer in silent mode, you should use the /S option:

"C:\path\to\installer.exe" /S

If you are running the installer from an administrator account, you can use the options /AllUsers and /CurrentUser to select whether you want to install ECLAIR for all users accounts or just for your own user account, respectively, the former being the default.

The use of installers in silent mode is particularly useful in automatic installation batch scripts. Remember, though, that even in silent mode, an installer is a GUI application and the command interpreter will not wait for its completion. If your next step in the script requires installation to be complete, you can invoke the installer as follows:

start "" /WAIT "C:\path\to\installer.exe" /S /AllUsers
Uninstallation with the Windows Uninstaller
Interactive Mode

Using the uninstaller is straightforward. The uninstaller can be invoked in interactive mode in three different but equivalent ways:

  • via the Add/Remove Programs section of the Windows Control Panel;

  • by clicking on the uninstall application of the relevant Start Menu folder;

  • directly, by executing uninstall.exe in the folder previously selected as the installing location.

The landing page of the uninstaller is similar to the following:

_images/Windows_Uninstall.png

By clicking on the Next button you can make sure you are uninstalling the version of ECLAIR you really want to uninstall:

_images/Windows_Uninstall_Confirm_Admin.png

At the end of uninstallation, a completion page will be displayed:

_images/Windows_Uninstall_Completing.png
Silent Mode

Similar to installers, uninstallers can also be run in silent mode by using the /S option, as in

"C:\Program Files\BUGSENG\eclair-3.14.0\uninstall.exe" /S

Note that the ECLAIR uninstallers will never uninstall Sentinel LDK Run-Time Environment (which may be used to protect other applications). When run from an administrator account, the uninstallers will remove BUGSENG add-ons to Sentinel LDK RTE.

Installation from a Zip File

For Windows platforms, ECLAIR can be shipped in the form of a zip file named

eclair-DELIVERY-PLATFORM.zip

where DELIVERY is a string that identifies the delivery (typically including a customer id and a date), and PLATFORM is a string like i686-windows or x86_64-windows identifying the platform under which this distribution of ECLAIR will run.

To install ECLAIR, simply unzip the file into a the location PREFIX that has been chosen as the installation prefix. Assuming VERSION is the version installed, the unzip operation will create folder

PREFIX\eclair-VERSION

So, if you installed a specific version of ECLAIR, say 3.14.0, the main executable files will be in folder

PREFIX\eclair-3.14.0\bin

Before proceeding further, make sure the above folder is in your PATH environment variable.

Installation of Sentinel LDK Run-Time Environment

The installation and uninstallation of Sentinel LDK run-time environment can be easily done from the command line via the batch files

PREFIX\eclair-VERSION\reqs\Sentinel_LDK_RTE\sntl_install.bat

and

PREFIX\eclair-VERSION\reqs\Sentinel_LDK_RTE\sntl_uninstall.bat

respectively. Please note that these should be run with administrator privileges.

Note

The installation of the Sentinel LDK run-time environment is known to interfere with some antivirus/anti-malware software. Make sure you disable all antivirus/anti-malware programs before installation and uninstallation of Sentinel LDK run-time environment. Do not forget to re-enable them afterwards.

Installation on a Un*x-like System

The supported installation procedures for Un*x-like operating systems are as follows.

Installation and Uninstallation with the Un*x Installer

For most uses, the most convenient way to install ECLAIR on a Un*x-like platform is via an installer.

Installation with the Un*x Installer

The ECLAIR Unix installers can be used both by the root account and by ordinary user accounts. In the second case, the installer will be unable to install the Sentinel LDK Run-Time Environment along with the BUGSENG add-ons, which are prerequisites for the installation of ECLAIR; this is not a problem if both of these have already been installed on the machine.

Warning

Sentinel LDK RTE is a strong prerequisite

Do not use the ECLAIR Un*x installers from an ordinary user account unless you know that the installer has already been run by root (possibly via sudo) on the same machine.

It is important that you ensure no ECLAIR component are running before starting installation: if in doubt, restart the machine.

Running with root Privileges

Let us start with the simplest case, where the installer is run via sudo. In this case, the installer will welcome you as follows:

$ sudo ./ECLAIR_3.14.0-MC23P1-l64P_Setup.run

This procedure will install ECLAIR 3.14.0 (3.14.0-MCP-l64P).
Hit RETURN to browse the LICENSE AGREEMENT...

There you can see the ECLAIR version (3.14.0 in this example), the maximal combination of packages the platform may be instantiated upon (MCP), the architecture (l64, for Linux/x86_64), and a license-kind identifier (P in this example, from Professional, as opposed to Trial or Educational).

Hitting the RETURN key will cause invocation of a text browser on the license agreement:

The entire ECLAIR system is protected commercial software owned by
BUGSENG srl.  Use of the ECLAIR system is only possible in the context
of a LICENSE AGREEMENT between BUGSENG srl and your company ("LICENSEE"
in the sequel).  The essential parts of the LICENSE AGREEMENT are
reproduced below.

Any reproduction or redistribution of any part of the ECLAIR system
not in accordance with the LICENSE AGREEMENT is expressly prohibited
by law, and may result in severe civil and criminal
penalties. Violators will be prosecuted to the maximum extent
possible.

Without limiting the foregoing, copying or reproduction of any part of
the ECLAIR system to any server or location for further reproduction
or redistribution is expressly prohibited.  The extensive and
systematic use of digital watermarking techniques ensures that each
delivered version of ECLAIR, or part thereof, can always be traced
back to the original authorized recipient.

______________________________________________________________________
______________________________________________________________________

ECLAIR LICENSE AGREEMENT
--More--(0%)[Press space to continue, 'q' to quit.]

Scroll down through the license and, if you agree to its terms, type y. You will be then asked for the installation directory:

Please type y to accept, n otherwise: y
Verifying archive integrity... 100%   MD5 checksums are OK. All good.
Uncompressing ECLAIR 3.14.0 (3.14.0-MCP-l64P)  100%

Please select the installation directory
(default /opt/bugseng/eclair-3.14.0):

Whether you accept the default installation directory or provide a different one, the installer will offer to create the required directories. If the last component of the installation path is not eclair, a symbolic link will be created with that name (unless the link is already present):

Please select the installation directory
(default /opt/bugseng/eclair-3.14.0):
'/opt/bugseng', the parent of '/opt/bugseng/eclair-3.14.0', does not exist
Attempt creation of '/opt/bugseng'? [y/N]  y
This step can take several minutes: please do not interrupt the installation process.
gtk-update-icon-cache: Cache file created successfully.
Created symbolic link '/opt/bugseng/eclair' -> '/opt/bugseng/eclair-3.14.0'.

Warning

The chosen installation directory cannot contain spaces, as that would prevent ECLAIR from functioning correctly. If such a path has been chosen, the safest choice is to uninstall the software and rerun the installer.

Note that, if the installation directory already exists, the installer will ask you to choose a different one:

Please select the installation directory
(default /opt/bugseng/eclair-3.14.0):
'/opt/bugseng/eclair-3.14.0' exists: will not overwrite

Please select the installation directory
(default /opt/bugseng/eclair-3.14.0): /new/bugseng/eclair-3.14.0
'/new/bugseng', the parent of '/new/bugseng/eclair-3.14.0', does not exist
Attempt creation of '/new/bugseng'? [y/N]  y
Created symbolic link '/new/bugseng/eclair' -> '/new/bugseng/eclair-3.14.0'.

If you prefer, you can exit the installer, erase the old installation directory tree, and restart the installer.

In any case, the process will continue with the installation/upgrade of Sentinel LDK RTE. Here is, e.g., what this step looks like on an Ubuntu system where Sentinel LDK RTE is not yet present:

Install .DEB on this system
Selecting previously unselected package aksusbd.
(Reading database ... 185799 files and directories currently installed.)
Preparing to unpack .../pkg/aksusbd_10.11-1_amd64.deb ...
Unpacking aksusbd (10.11-1) ...
Setting up aksusbd (10.11-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/aksusbd.service → /etc/systemd/system/aksusbd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/hasplmd.service → /etc/systemd/system/hasplmd.service.
Install VLIB
Install EMSUrl

Installation of Sentinel LDK RTE 10.11 completed.
Point your browser to http://localhost:1947 to access
the Sentinel Admin Control Center.

When the installer is run with root privileges, it will automatically take care of all aspects of Sentinel LDK RTE installation.

At this stage you will be offered to generate the machine fingerprint. Answer positively if you need a node-locked protection key or if you are installing a machine you want to act as license server. Here is a sample dialogue:

You can now collect the fingerprint of this computer
to enable the installation of a new protection key.
Collect fingerprint? [y/N]  y
Computer fingerprint is in file '/tmp/fingerprint_b3m.c2v'.
Please rename it to 'fingerprint_N.c2v' (with N in 1,2,...) and send it
to BUGSENG support services for license activation.

Whatever your answer was to the question about collecting the fingerprint, installation is now complete and the installer prints some information and advice before giving control back to the shell:

ECLAIR 3.14.0 (3.14.0-MCP-l64P) installation complete.

The manual in PDF and HTML format is available in
'/opt/bugseng/eclair-3.14.0/share/doc/manual/ECLAIR_3.14.0-MCP-l64P.pdf'
and '/opt/bugseng/eclair-3.14.0/share/doc/manual/index.html'.

You can add '/opt/bugseng/eclair-3.14.0/bin' or '/opt/bugseng/eclair/bin'
to the PATH environment variable.

A complete installation log is availabe in '/tmp/ECLAIR_installation_log_HUF.txt'
$
Running without root Privileges

When the installer starts, it will check whether it is running with root privileges. If not, it will offer to continue by displaying the commands that have to be executed with root privileges. Here is a sample dialogue:

$ ./ECLAIR_4.0-MC23P1-l64P_Setup.run

This procedure will install ECLAIR 3.14.0 (3.14.0-MCP-l64P).

The entire ECLAIR system is protected commercial software owned by
BUGSENG srl.  Use of the ECLAIR system is only possible in the context
of a LICENSE AGREEMENT between BUGSENG srl and your company ("LICENSEE"
in the sequel).  The essential parts of the LICENSE AGREEMENT are
reproduced below.

[...]

Please type y to accept, n otherwise: y
Verifying archive integrity... 100%   MD5 checksums are OK. All good.
Uncompressing ECLAIR 3.14.0 (3.14.0-MCP-l64P)  100%

Not running as root does not allow directly installing Sentinel LDK RTE,
but the commands to be executed as root can be displayed for later execution.
Do you want to proceed as non-root? [y/N]  y

Please select the installation directory
(default /opt/bugseng/eclair-3.14.0): /home/joe/eclair-3.14.0
This step can take several minutes: please do not interrupt the installation process.
gtk-update-icon-cache: No theme index file.
Created symbolic link '/home/joe/eclair' -> '/home/joe/eclair-3.14.0'.

# Execute the following commands to install Sentinel LDK RTE 10.11.
tar zxf '/home/joe/eclair-3.14.0/reqs/Sentinel_LDK_RTE/aksusbd-10.11.1.tar.gz'
cd 'aksusbd-10.11.1'
sudo ./dinst .

Please install Sentinel LDK RTE 10.11 in order to complete
the installation of ECLAIR 3.14.0 (3.14.0-MCP-l64P).

Once installed, point your browser to http://localhost:1947 to access
the Sentinel Admin Control Center.

At this stage you can also collect the fingerprint of this computer
to enable the installation of a new protection key, e.g. using the command:

'/home/joe/eclair-3.14.0/bin/eclair_licman' -s l -F -o fingerprint_N.c2v

Please substitute N with 1,2,... in 'fingerprint_N.c2v' and send the result
to BUGSENG support services for license activation.

The manual in PDF and HTML format is available in
'/home/joe/eclair-3.14.0/share/doc/manual/ECLAIR_3.14.0-MCP-l64P.pdf'
and '/home/joe/eclair-3.14.0/share/doc/manual/index.html'.

You can add '/home/joe/eclair-3.14.0/bin' or '/home/joe/eclair/bin'
to the PATH environment variable.

A complete installation log is availabe in '/tmp/ECLAIR_installation_log_Swm.txt'
$

The block of lines starting with

# Execute the following commands to install Sentinel LDK RTE 10.11.

is what you have to send to a sysadmin in order to explain what needs to be done with root privileges.

Manual Uninstallation

Uninstallation is straightforward, unless you want to uninstall Sentinel LDK Run-Time Environment as well, and can be done by simply removing the xdg associations, the installation directory and, possibly, the corresponding eclair symbolic link. If the installer was run with root privileges, this can be done as follows:

# Remove the xdg associations.
sudo /opt/bugseng/eclair-3.14.0/bin/xdg-install.sh -u
# Remove the installation directory.
sudo rm -rf /opt/bugseng/eclair-3.14.0
# Remove the 'eclair' symbolic link, if any.
sudo rm -f /opt/bugseng/eclair

Of course, sudo needs not be used if the installer was run without privileges:

# Remove the xdg associations.
/home/joe/eclair-3.14.0/bin/xdg-install.sh -u
# Remove the installation directory.
rm -rf /home/joe/eclair-3.14.0
# Remove the 'eclair' symbolic link, if any.
rm -f  /home/joe/eclair

If you are sure Sentinel LDK Run-Time Environment is not required by other applications in the system and you want to uninstall it, then the above steps must be preceded by the following commands (where, of course, /opt/bugseng/eclair-3.14.0 should be replaced by the actual installation directory):

cd /tmp
tar zxf '/opt/bugseng/eclair-3.14.0/reqs/Sentinel_LDK_RTE/aksusbd-8.23.1.tar.gz'
cd 'aksusbd-8.23.1'
sudo ./dunst

Installation from a Tarball

ECLAIR can be very easily installed from a tarball, that is, a file named

eclair-DELIVERY-PLATFORM.tar.gz

where DELIVERY is a string that identifies the delivery (typically including a customer id and a date), and PLATFORM is a string like i686-linux or x86_64-linux identifying the platform under which this distribution of ECLAIR will run.

Once PREFIX has been chosen as the installation prefix, the steps to be performed are the following:

cd PREFIX
tar zxf eclair-DELIVERY-PLATFORM.tar.gz

Next, ensure that the PATH environment variable contains

PREFIX/eclair/bin

Notice that, on Un*x-like systems, PREFIX/eclair/bin is just a symbolic link to PREFIX/eclair-VERSION/bin, where VERSION is the version of ECLAIR that was installed the latest. So, if you want to use a fixed, specific version of ECLAIR, say 3.14.0, the PATH environment should instead point to

PREFIX/eclair-3.14.0/bin
Post-installation on Linux Systems

In order to accommodate for a possible mismatch between the C library installed in your system and the one expected by the just-installed version of ECLAIR, run the command

postinstall.sh

In order to configure your desktop environment, run the command

xdg-install.sh

The script will:

  • add to your applications list two icons: one for eclair_gui and one for eclair_report;

  • create an association between the .ecs files and eclair_gui, then it will be possible to open a .ecs file simply by double clicking on it;

  • create an association between the .ecd files and eclair_report, then it will be possible to open a database file simply by double clicking on it. eclair_report will open in a new browser tab, and the server will shut down ten seconds after closing all tabs.

If you run the script as superuser the changes will be available for all the users, otherwise they will be available only for the user who launches the script.

xdg-install takes an optional argument -u, running the script with this option all the changes listed above will be reverted, if run as superuser the changes will be reverted for all the users.

The script may exit with status 255, and show the following message:

gtk-update-icon-cache: No theme index file.

Please ignore it, it’s normal. All the features listed above aren’t affected by the error.

Installation of Sentinel LDK Run-Time Environment on macOS Systems

To installation Sentinel LDK run-time environment on an macOS system mount one of the DMG files in the directory PREFIX/eclair-VERSION/reqs/Sentinel_LDK_RTE:

  • Sentinel_Runtime_Installer_GUI.dmg for installation and uninstallation using a GUI;

  • Sentinel_Runtime_Installer_Scripts.dmg for script-based installation and uninstallation.

After the installation has been performed, manually copy the file PREFIX/eclair-VERSION/reqs/Sentinel_LDK_RTE/haspvlib_113938.dylib to directory /var/hasplm.

Note

The installation of the Sentinel LDK run-time environment is known to interfere with some antivirus/anti-malware software. Make sure you disable all antivirus/anti-malware programs before installation and uninstallation of Sentinel LDK run-time environment. Do not forget to re-enable them afterwards.

Installation of Sentinel LDK Run-Time Environment on Linux Systems

The installation of Sentinel LDK run-time environment is very easy on Ubuntu, Debian, SUSE, CentOS, and RedHat Linux systems for which ready-to-use packages are provided. The directory PREFIX/eclair-VERSION/reqs/Sentinel_LDK_RTE contains the compressed archive file aksusbd-*.tar.gz and the corresponding instructions in README_aksusbd-*.tar.gz.html: extract all files in the archive with the command tar zxf aksusbd-*.tar.gz, go into the newly-created directory aksusbd-*, and follow the instructions in the HTML file (for which you will need administrator privileges).

Activation of Node-Locked License Keys

If you purchased node-locked license keys, these need to be activated. The activation has two phases: first a machine fingerprint is obtained and sent to BUGSENG; then an activation file sent by BUGSENG should be applied on that machine. Let us suppose 5 node-locked license keys have been purchased and that the machines machine_1, …, machine_5 have been selected to host them. Then the command

eclair_licman -s l -F -o fingerprint_N.c2v

should be executed on machine_N and the resulting file fingerprint_N.c2v should be sent to BUGSENG via the issue-tracking system. BUGSENG will reply by providing the file activation_N.v2c, which should then be installed, either via Sentinel Admin Control Center (using the Update/Attach option), or by executing the command

eclair_licman -A activation_N.v2c -o ack_N.c2v

on machine_N. The resulting file, ack_N.c2v, should be sent to BUGSENG via the issue-tracking system: this is essential for future license keys’ updates and upgrades.

In order to check that the license key has been activated, open the Sentinel Admin Control Center with any web browser.

Activation of Detachable License Keys

If you purchased detachable license keys, these need to be activated. The procedure is very similar, but involves only the machine(s) that will host your license key pool(s): let us call such machines the license servers. The activation has two phases: first a fingerprint of each license server is obtained and sent to BUGSENG; then one activation file for each pool that will be hosted by that license server will be sent by BUGSENG and should be applied on that machine.

The machines that will only use detachable keys, let us call them the client machines, only need installation of the same ECLAIR version and their fingerprint is unneeded.

For information concerning the use of detachable keys, both on the license servers and on the client machines, please consult the relevant section of Sentinel Admin Control Center documentation available at http://localhost:1947/_int_/ACC_help_detach_license.html .

Rehosting Licenses Keys

It is sometimes necessary to transfer a license key from one computer (the source computer) to another (the recipient computer). This is a seven-step procedure, called rehosting, that requires the involvement of BUGSENG support personnel. The procedure steps are the following:

Step 1: Start the Rehosting Process

Open an issue on BUGSENG’s issue-tracking system where you explain why you need to rehost the license key and attach the C2V file for the license in question. You can generate the required C2V either from the Sentinel Admin Control Center or by issuing the following command on the source computer:

eclair_licman -U -o fingerprint_u_source.c2v

You will have to add an option like -sk=376724310135079624 in case you have multiple license keys installed and that the license key to be rehosted is 376724310135079624. You can use the eclair_licman -S K command to list the available license keys.

Step 2: Initialize Rehosting on the Source Computer

You will then receive an email from the BUGSENG EMS Service (ems@bugseng.com) with the subject “LDK-EMS - License Certificate” and containing a V2C file to update your key on the source computer. To install the license update, you can visit the EMS Customer Portal and, with a single click, you can install the update. Alternatively, you can install the update manually using the attached V2C file, through the Update/Attach option of Sentinel ACC. You can also issue a command like the following on the source computer (the name of the V2C file will of course have to be adapted):

eclair_licman -A 376724310135079624.v2c -o ack_ris.c2v
Step 3: Collect Information About the Recipient Computer

Make sure the Sentinel LDK run-time environment is installed and running on the recipient computer. Then, on the recipient computer, execute the command

eclair_licman -I -o fingerprint_i_recipient.c2v

and transfer the generated file fingerprint_i_recipient.c2v to the source computer.

Step 4: Generate the License Key Transfer File

On the source computer, first identify the license key to be transferred using the Sentinel Admin Control Center: suppose the license key is 376724310135079624. Then execute the command

eclair_licman -R 376724310135079624 -r fingerprint_i_recipient.c2v \
  -o rehost_source_recipient.h2h

and transfer the generated file rehost_source_recipient.h2h to the recipient computer.

Step 5: Apply the License Key Transfer File

On the recipient computer, install rehost_source_recipient.h2h, either via Sentinel Admin Control Center, or by executing the command

eclair_licman -A rehost_source_recipient.h2h
Step 6: Prepare for Finalizing the Rehosting Process

Upload to the relevant issue in BUGSENG’s issue-tracking system the C2V file for the just-rehosted license key. You can generate the required C2V either from the Sentinel Admin Control Center or by issuing the following command on the recipient computer:

eclair_licman -U -o fingerprint_u_recipient.c2v

You will have to add an option like -sk=376724310135079624 in case you have multiple license keys installed and that the just-rehosted license key is 376724310135079624.

Step 7: Finalize Rehosting on the Recipient Computer

At this point you will receive another email from the BUGSENG EMS Service (ems@bugseng.com) with the subject “LDK-EMS - License Certificate” and containing a V2C file to update your key on the recipient computer. This update can be installed directly by either by clicking the link in the email, or by installing the update using Sentinel ACC, or by issuing the following command on the recipient computer:

eclair_licman -A 376724310135079624.v2c -o ack_rfr.c2v

and upload the resulting ack_rfr.c2v file to the relevant issue in BUGSENG’s issue-tracking system. As usual, you can check that rehosting took place as expected by using the Sentinel Admin Control Center.

Note

Rehosting, while cumbersome, is a very important operation and in some cases it is the only way to make sure the license key is not lost forever. Do rehost your license keys:

  • at the first sign of likely system failure (e.g., file corruption, unusually noisy fans or hard drives, occasional crashes or boot errors, degraded performance);

  • before replacing hardware components, the BIOS or the operating system (you can always transfer the license key back after the upgrade).

Controlling the Network Activity of Sentinel License Managers

By default, the Sentinel license managers emit broadcast packets in order to sense the presence of remote license keys. This behavior can be changed by accessing the Access to Remote License Managers tab available at http://localhost:1947/_int_/config_to.html . This is the meaning of the options:

Allow Access to Remote Licenses

Enables or disables access to remote network keys.

Broadcast Search for Remote Licenses

Enables or disables access to UDP broadcast search. This kind of search is performed before the Aggressive Search with parameters (see below)

Aggressive Search for Remote Licenses

Will perform a TCP request instead of a UDP; this will intensify network traffic and is not recommended with the Broadcast Search enabled. However, this is useful when used in combination with Specify Search Parameters.

Specify Search Parameters

If Aggressive Search for Remote Licenses is enabled, a TCP search will be performed on the specified addresses.

Running ECLAIR in Docker Containers

Running ECLAIR in Docker containers may be needed in some contexts. Dockerization brings with it a number of advantages such as reproducibility of the build, isolation of the host environment, and shareability.

Docker containers are particularly appropriate for CI/CD workflows.

A very crucial aspect of dockerization is how to link the license to the container, we suggest one of the following possibilities with a preference for the first one (their applicability depends on your environment and licensing):

  • install Sentinel and the keys only in the host environment, and let the ECLAIR instance in the container fetch them via the network. This option is suitable even if the license server is installed on a different machine as long as it is in the same network (this configuration should not be used just to avoid network issues and poor performance).

  • install Sentinel on the container and, when required, detach a license key from a license server (that could be the host itself or another machine). This option requires detachable license keys and if the container does not return the license key, it will remain unavailable until it expires. Set the maximum detach duration accordingly. Once the key is detached and installed in the container this option guarantees the best performance as the features retrieval is local.

We have prepared a Dockerfile for the first option that can be used as a skeleton for your containers:

PREFIX/eclair-VERSION/share/docker/Dockerfile

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation).

Please adapt the Dockerfile where needed and extend it with all the required software to build your project.

Place the ECLAIR installer in the same directory as the Dockerfile, then run the following command to build the Dockerfile:

docker build -t ECLAIR-container .

After building the container, you can execute it with:

docker run -it ECLAIR-container /bin/bash

The second option requires having Sentinel on the container; follow the instructions contained in the Dockerfile to add the Sentinel installation. A small demonstration showing use of ECLAIR in Docker containers for the second option can be found in the following demo:

ECLAIR-MAJ_MIN_demo_crc_Docker

where MAJ_MIN is the major and minor version numbers of ECLAIR separated by a dot (it corresponds to the complete version number by removing the final patch number).

See the REAMDE.txt file contained in the demo for further information.

Warning

You must never move/delete the Sentinel operational directories!

The volumes /var/hasplm and /etc/hasplm defined in the container are the directories where Sentinel LDK RTE stores its configurations and operational files.

The container must be configured to mount these two directories in persistent locations on the host machine.

This is a quite significant point because in this way it is possible to create persistent configurations or use/share already existing instances of Sentinel.

To avoid unexpected behaviors, do not share these directories with machines running at the same time Sentinel (this includes the host machine) and do not provide system directories.

If the container is intended to be used only as license server, please refer instead to the following demo:

ECLAIR-MAJ_MIN_License_Server_Docker

Using ECLAIR from the Command Line

This chapter describes three different commands to use ECLAIR: eclairit, eclair_env, and eclair_licman. The former is the simplest and quickest way to use ECLAIR, excellent for a first approach to the tool; the second is the “standard” way of using ECLAIR with its wide range of configurations and services; the latter is used to manage license keys.

The eclairit Command

The eclairit command launches the ECLAIR simple driver: it allows to run a build command in an ECLAIR environment to perform some predefined analyses in a very simple way, without requiring any configuration from the user. At the end of the analysis, the results are opened in the default web browser.

The ECLAIR simple driver is invoked as follows:

eclairit [OPTION]... -- COMMAND

Where:

COMMAND is the only mandatory argument: it shall be any command that cleans and (re)builds (part of) a C/C++ project without errors. The reason is that ECLAIR checkers are run only on those units that are recompiled by the build command. So, to redo the ECLAIR checks on all the compiled files, it is best to clean the project (e.g., with make clean) before (re)building it.

[OPTION]... is a (possibly empty) list of options to configure some aspects of the ECLAIR simple driver (such as -s to select the checks to enable). If no options are given, default configurations are used and the project is analyzed with respect to a selection of BARR-C:2018 rules [8].

Available eclairit Options

The program eclairit can be used without specifying any options, however several are available to tune your analysis. A brief description of such options can be obtained by executing eclairit -h or eclairit --help. In the following sections these options are explained in greater detail.

Option –service_set (-s)
--service_set <SERVICE_SET>, -s <SERVICE_SET>

By default eclairit runs the analysis on a selection of BARR-C guidelines, but via the --service_set or -s options it is possible to select a different set of ECLAIR services to be enabled; the possible values are: - BARR-C - BF - METRICS - MISRA-C - MISRA-Cxx - MISRA-Cxx - sel-BARR-C - sel-BF - sel-METRICS - sel-MISRA-C - sel-MISRA-Cxx

Option –output_dir (-o)
--output_dir <DIR>, -o <DIR>

The output directory of the program eclairit is generated in the current working directory when the command is invoked unless via the --output_dir or -o a different location is specified.

If the option --browse_only is specified then the value of --output_dir shall be the output directory of a previous analysis.

Option –projectRoot (-p)
--projectRoot <DIR>, -p <DIR>

The root directory relative to which all files to be analyzed are assumed to be present. It is analogous to the eclair global -project_root.

Option –config (-c)
--config <FILE>, -c <FILE>

This options allows an external .ecl file to be evaluated during the analysis. It is analogous to the eclair global -eval_file.

Option –quiet (-q)
--quiet, -q

This option sets the command not to print any unnecessary information on the standard output.

Option –analyze_only (-a)
--analyze_only, -a

This option sets the command not to visualize the output in the browser, and to end after the generation of the results of the analysis.

Option –browse_only (-b)
--browse_only, -b

The option --browse_only allows visualizing previous generated results without needing to run any additional analysis.

Examples of eclairit uses

Some example of use of the eclairit command:

Example:

eclairit -s BARR-C -- gcc -c -DNDEBUG -m32 p.c

analyze the project with respect to BARR-C:2018 coding standard [8]

Example:

eclairit -s BF -o /tmp/eclairit_BF -- clang -g p.c q.c

analyze the project searching for possible bugs and write the results in /tmp/eclairit_BF

Example:

eclairit -s METRICS -analyze_only -- ./clean_and_build.sh

analyze the project to compute software quality metrics (such as HIS Source Code Metrics [13]) without opening the results at the end of the analysis

Example:

eclairit -s MISRA-C -- make rebuild

analyze the project with respect to MISRA C:2025 coding standard [59]

Example:

eclairit -s MISRA-Cxx -- /opt/gcc-arm-none-eabi/bin/arm-none-eabi-gcc p.c

analyze the project with respect to MISRA C++:2023 coding standard [56]

Example:

eclairit -b

browse the results of the previous analysis

The eclair_env Command

The eclair_env command introduces an environment in which ECLAIR is able to intercept invocations of the key toolchain components and obtain all the information it needs about the project’s programs and/or libraries. ECLAIR is called like this:

eclair_env [OPTIONS] [-- [COMMAND [ARGUMENTS]]]

where OPTIONS is a sequence of eclair_env options and COMMAND is any command with ARGUMENTS as its arguments.

Typical commands include (but are not limited to):

  • compiler and/or linker invocations:

    eclair_env [OPTIONS] -- cc -O2 -g -DNDEBUG=1 -o prog src1.c src2.c
  • invocations of make-like build systems:

    eclair_env [OPTIONS] -- make -j 8
  • invocation of other build systems:

    eclair_env [OPTIONS] -- rpmbuild --rebuild httpd-2.2.10-2.src.rpm
  • invocation of just any script:

    eclair_env [OPTIONS] -- ./build.sh -u kernel=MYKERNEL

When compiling the project code with ECLAIR, it is possible to reduce the CPU time used for compilation by configuring the project build without optimizations.

ECLAIR checkers are run only on those units that are recompiled by the build system. So, to redo the ECLAIR checks on all the compiled files, it is best to run make clean on the build system before invoking ECLAIR.

eclair_env options

The options are:

Option +incremental
+incremental

do not clear previously stored project information and not doing final project wide analysis

Option +clean
+clean

clear any previously stored project information (as without this option) but do not perform the final project wide analysis

Option +project
+project

without clearing previously stored project information, do final project wide analysis (as without this option)

Other options
-<OPTION>=<VALUE>

where <OPTION> is a global option or a generic service option and <VALUE> is either an individual term or a list of terms enclosed in braces and separated by , or =.

The <OPTION> can be preceded by + or ! or followed by + or - and the different forms have the following semantics:

-<OPTION>=<VALUE>

set or reset the option values to <VALUE> replacing any pre-existing values. If pre-existing values are overwritten a warning will be produced;

-+<OPTION>=<VALUE>

prepend the option value <VALUE> to any pre-existing values;

-<OPTION>+=<VALUE>

append the option value <VALUE> to any pre-existing values;

-<OPTION>-=<VALUE>

delete the option value <VALUE> from any pre-existing values.

-!<OPTION>=<VALUE>

overwrite the option values to <VALUE> replacing any pre-existing values. If pre-existing values are overwritten no warnings will be produced;

Note:

Terms in VALUE should be quoted if they contain characters different from A-Z, a-z, 0-9 or _. If the eclair_env command option is given from the shell command line, the shell quoting rules should be taken into account.

Here, as examples, are some useful global options.

Example:

-eval_file=FILE_NAME,...

loads the configuration contained in file FILE_NAME (see -eval_file).

Example:

-project_name=PROJECT

sets PROJECT to be the project name (see -project_name).

Example:

-project_root=PROJECT_DIRECTORY

sets PROJECT_DIRECTORY as the path for the top source directory of the project named PROJECT, any references to files below this directory are given with a path relative to the directory (see -project_root).

Incremental Configuration

When more than one ECLAIR command options is provided, eclair_env will process them one by one in the specified order (from left to right). For example, the ECLAIR command options can be provided by several configuration files, each included using the command option -eval_file, together with other options written directly on the command line.

This behavior can be usefully exploited; for instance, to incrementally construct a complete configuration composed of smaller pieces, from different configuration files, thereby easing the reuse of common configurations by several different projects:

eclair_env -eval_file=prj_cfg_base.ecl \
  -eval_file=prj_cfg_exp.ecl -- make

Environment Variables

ECLAIR_DIAGNOSTICS_OUTPUT

When defined, its value specifies the output sink receiving the ECLAIR diagnostics output, which defaults to the standard error output stream (see the section on specifying output sinks for more information about output specifications).

ECLAIR_WORKSPACE

When defined, its value is the directory containing the ECLAIR workspace, which defaults to the .eclair subdirectory of user’s home directory. Note that execution privilege is required for the area containing the ECLAIR workspace.

Parallel Builds

Parallel builds (e.g., on make-based build systems, those obtained with make -j [jobs]) are fully supported by eclair_env. For the rare cases where direct textual output is required, the only precaution that should be taken concerns synchronization of the output to the same file of the various instances of eclair_env that are in concurrent execution. Synchronization can be achieved very simply by means of the atomic_append program. An output specification expressing a synchronized output sink has the form |atomic_append FILE (see the section on specifying output sinks for more information about output specifications). A typical invocation of eclair_env on a parallel verification task is:

"-config=B.REPORT.TXT,output='|atomic_append FILE'"

Another possibility is to use a different output file for each analysis frame:

"-config=B.REPORT.TXT,output='FILE_PREFIX@FRAME@.FILE_SUFFIX'"

Note that binary output, requested by service B.REPORT.ECB, is almost always a far superior alternative and does not require any precaution as far as parallel builds are concerned.

The eclair_licman Command

eclair_licman is a command-line tool used for managing ECLAIR license keys. It supports various operations such as license key installation, update, rehosting, and detaching.

Usage:

eclair_licman [OPTIONS]

where OPTIONS is a sequence of eclair_licman options.

Most actions available with this command can also be performed using the Sentinel Admin Control Center, as detailed in the Installation chapter. However, some operations specific to license key rehosting are exceptions (see Rehosting Licenses Keys).

Below you will find some use cases for eclair_licman.

Activation of License Keys

This process consists of three steps that need to be performed on either the machine where the license will be installed (if you have purchased a node-locked license) or the license server (if you have a floating license). These steps include:

  • collecting a fingerprint of the machine where the license key will be installed;

  • sending the fingerprint to BUGSENG and receiving an activation file;

  • applying the activation file to the machine.

See Activation of Node-Locked License Keys for more information.

Detach a Floating License Key

Let us suppose that you have an active floating license key and you want to detach it from the network pool to temporarily assign it to another machine. This can be done with an express detach (-d) operation.

First, we can list the available products that are visible from this host:

eclair_licman -S P

You will be given a list of products with their respective IDs. For example:

Name       Id     Host       IP              Detachable  Cloned
product_1  12345  host_name  XXX.XXX.XXX.XXX true        accepted
product_2  67890  host_name  XXX.XXX.XXX.XXX false       accepted

In this case we can see that product_1 is detachable. We can then detach it with the following command:

eclair_licman -d 12345 -t 3600

where 12345 is the ID of the product to detach. The -t option specifies the detach time in seconds (1 hour in this case) before the detach is automatically canceled and the license key is returned to the network pool. If you don’t specify the -t option, a default value specified in the eclair_licman help (-h option) will be used.

A detach can be explicitly canceled at any time with the following command:

eclair_licman -c 12345

where 12345 is the ID of the product to cancel the detach. The license key will be returned to the network pool.

License Key Rehosting

This procedure allows you to transfer a license key from one machine (the source computer) to another machine (the recipient computer). The process consists in several steps, which are outlined in detail in Rehosting Licenses Keys.

Options for License key installation and update

Option -F
-F

collect and output a fingerprint of this computer to enable the installation of a new protection key.

Option -U
-U

collect and output information to enable the update of an existing protection key.

Option -A
-A <FILENAME>

apply the license (update) contained in <FILENAME>.

Options for License key rehosting

Option -I
-I

collect and output a fingerprint of this computer to enable the rehosting of an existing protection key.

Option -R
-R <KEY_ID>

rehost the protection key <KEY_ID> to another machine.

Option -r
-r <FILENAME>

use the fingerprint in <FILENAME> to identify the destination machine for a rehost or detach.

Options for Floating license key detach and cancel

Option -d
-d <PRODUCT_ID>

express detach.

Option -t
-t <SECONDS>

specify the time, in seconds, for a detach operation (the default value can be found in the help text with the -h option).

Option -c
-c <PRODUCT_ID>

express cancel detach.

Miscellanea Options

Option -S
-S <PAGE>

query the current hasp installation, where <PAGE> is one of:

  • p or P to show the BUGSENG products that are visible from this host

  • f or F to show the features attached to each product key visible on this host. Option -s k=<KEY_ID> can be used to filter the results

  • k or K show the BUGSENG keys that are visible on this host

Use the uppercase variants of <PAGE> to get aligned output.

Option -o
-o <FILENAME>

direct output to <FILENAME> (default to stdout).

Option -v
-v

display version information on stderr and continue.

Option -h
-h

display help text on stderr and exit.

Advanced Options

Option -C
-C <KEY_ID>

cancel the detached license <KEY_ID> and return it to the network pool before the scheduled expiration.

Option -D
-D <PRODUCT_ID>

detach a license key from a pool of network seats to temporarily assign it to another machine.

Option -s
-s <SCOPE>

defines the scope of the key search, where <SCOPE> is one of:

  • u: unrestricted search (default)

  • h: search HL keys only

  • l: search local keys only

  • j: search local HL keys only

  • r: search remote keys only

  • m=<LM_NAME>: specified license manager name

  • i=<LM_IP>: specified license manager IP address

  • k=<KEY_ID>: specified key id

  • p=PRODUCT_ID: specified product id

Using ECLAIR from the GUI

The eclair_gui launches the graphical user interface of ECLAIR, called the ECLAIR GUI or simply the GUI in the sequel. The ECLAIR GUI facilitates the following tasks:

  • selecting the services to be enabled;

  • selecting the toolchain components to be intercepted;

  • defining the build process;

  • defining sets of files that should not be analyzed or should be considered as uninteresting for the purpose of reporting.

The GUI allows saving an ECLAIR settings file, with filename extension file:.ecs for later use. It also allows running the analysis and browsing the results.

The GUI is invoked as follows:

eclair_gui [OPTIONS] [FILE.ecs]

where OPTIONS is a sequence of eclair_gui options and FILE.ecs is an optional file containing ECLAIR settings, typically produced in the course of a previous GUI session.

Available eclair_gui Options

Option –headless, (-h)

--headless, -h

run in headless mode;

Option –run, (-r)

--run <CONF>, -r <CONF>

run the specified configuration <CONF> of FILE.ecs;

Option –server, (-s)

--server <URL>, -s <URL>

set <URL> as the URL for communication with the eclair_report server (default is http://127.0.0.1:3786);

Option –version, (-v)

--version, -v

print the GUI version number and exit.

The GUI is self-explanatory: in particular, all GUI elements provide on hover context-sensitive help messages. Moreover, detailed information about using the GUI for the visualization and navigation of the ECLAIR HTML outputs can be found in HTML Outputs.

Environment Variables

The advanced step “Environment” of the GUI allows to personalize environment variables. In particular, there are some environment variables that can be used to communicate with ECLAIR and personalize the analysis output.

These are:

ECLAIR_verbose

to control analysis log verbosity (false if unset);

ECLAIR_explain

to control the generation of configuration explanation (true if unset);

ECLAIR_full_doc_areas

to control shown report areas in .doc and .odt full output (false if unset);

ECLAIR_full_doc, ECLAIR_full_odt

to control generation of textual, .doc, and .odt full output (false if unset);

ECLAIR_full_txt_areas

to control shown report areas in textual full output (true if unset);

ECLAIR_full_txt

to control generation of textual full output (false if unset);

ECLAIR_summary_doc, ECLAIR_summary_odt, ECLAIR_summary_txt

to control generation of .doc, .odt and textual summary output (false if unset);

ECLAIR_metrics_tab

to control generation of .xlsm and .ods metrics spreadsheet (true if unset);

ECLAIR_reports_tab

to control generation of .xlsm and .ods reports spreadsheet (false if unset).

Integrating ECLAIR with IDEs, Editors, and CI Tools

The ECLAIR platform is extremely powerful and can be configured to perform a wide variety of automated software verification tasks. The platform can be used in isolation: besides the development toolchain and an editor, all that is required is an ordinary web browser for the analysis HTML outputs and an office suite to peruse the metrics in spreadsheet format and the printable summary outputs. ECLAIR can also be integrated with other tools. In this chapter we present the integration with IDEs, extensible editors and Continuous Integration (CI) tools.

Different Phases of the Work with ECLAIR

It is useful to distinguish different phases of the work with ECLAIR:

Static analysis

consists in running the build procedure under eclair_env, which will produce (possibly exploiting parallelism) a number of ECLAIR binary output files (see Section The eclair_env Command). Static analysis can take place on the developer’s desktop or on a remote server, wherever the build takes place.

Database generation

is performed using eclair_report: ECLAIR binary output files are assembled into one ECLAIR database file (see Section The eclair_report Command). This can take place on any machine, but it is worthwhile taking into account that the compressed binary output files are usually much smaller than the resulting database file. In other words, if the generation of outputs must take place on a machine different from the one where static analysis took place, transferring the compressed binary outputs is cheaper than transferring the database.

Output generation

is performed, again, using eclair_report to produce various kinds of outputs (see Chapter Outputs). Output generation can take place anywhere the ECLAIR database file is. We further distinguish two kinds of output generation:

offline output generation

is when eclair_report is used in batch mode to produce outputs in an external format (such as pure text or ODT summaries or, depending on the license, HTML or XML detailed outputs);

online output generation

is when eclair_report is used in client-server mode to interact with a web browser, an IDE or an extensible editor (these topics are further elaborated later in this chapter).

Output perusal

is of course performed on the developer’s desktop machine. If the perusal of detailed outputs is performed using an IDE or an extensible editor in order to be able to directly modify the program sources, then there are two possibilities:

  1. The static analysis machine and the developer’s desktop machines are the same, in which case, unless the program sources have been modified after the analysis, the outputs perfectly match the sources because the source files are the same.

  2. The static analysis machine and the developer’s desktop machines are not the same, but the working copy of the program sources in the developer’s desktop correspond to those that were analyzed (modulo a possibly different project root). This is the typical situation when static analysis is performed on an integration server and a version control system is used to maintain consistency between the working copies on different machines.

Different Ways of Working with ECLAIR

The flexibility of ECLAIR design allows supporting all sorts of workflows and distribution patterns. The following sections briefly illustrate the range of possibilities, which are of course not mutually exclusive.

Note that each possibility has technical requirements and licensing requirements. For example, the possibility of generating HTML detailed outputs is only available with certain license kinds: once detailed HTML outputs are generated, they can be browsed anywhere with the help of any web browser. As another example, a solution that requires running different ECLAIR components at the same time on different machines requires license keys to be available (maybe temporarily) on all the involved machines.

All ECLAIR Software Runs on the User’s Desktop

In this scheme only the user’s PC is involved. The main advantages are:

  1. only an individual user license is required;

  2. the user has full control of the analysis configuration and execution.

There are disadvantages as well:

  1. the user’s PC might not be powerful enough to perform the analysis of large projects with any combination of ECLAIR services in a time that is compatible with the work to be done;

  2. the user must be competent enough to operate ECLAIR configuration and execution, or someone has to setup everything up in the user’s PC.

Regarding the first disadvantage, the following points have to be taken into account:

  • If the user is not charged with the task of changing the code or the ECLAIR configuration (e.g., quality assurance personnel in charge of assessing a project under an existing configuration), then the analysis time may not be an issue (e.g., it can be done overnight).

  • If the user has to make source code changes in order to fix software errors and/or to improve compliance with respect to coding standards, he or she will typically work on one or a few source code files at a time. If the build system supports incremental builds, only the portion of the software affected by changes will be recompiled and thus, with the proper ECLAIR configuration, only that portion will be reanalyzed. If the ECLAIR configuration only enables single translation unit checkers the analysis time may be compatible with most sensible workflows.

In order to execute the analysis on his or her own PC, the user has two possibilities: using the ECLAIR GUI or using a script. GUI usage is described in Chapter Using ECLAIR from the GUI. Many demonstration projects available in BUGSENG’s issue-tracking system exemplify both possibilities, providing GUI configuration files as well as batch files, shell scripts, and ECL command files.

No ECLAIR-Connected IDE or Editor Involved

In this scenario, the user has performed the analysis either via the GUI or via scripting and will browse analysis HTML outputs using any web browser, either launched by the GUI or by simple scripting using the -browser and -server options of the eclair_report program.

The interaction with analysis outputs in the browser is described in Section HTML Outputs. If changes have to be made, the ECLAIR detailed reports will provide all the information required to manually direct the IDE or the editor to the program points where modifications have to be made.

External Build, Visualization Inside the IDE or the Editor

This scenario is similar to the previous one, with the difference that the user can visualize the reports inside the IDE or editor. Once ECLAIR has been installed within an IDE or editor, ECLAIR can be enabled by choosing the enable option from the dedicated ECLAIR menu. If the server is local and no server is running, the enable option will start an eclair_report server. Note that once ECLAIR is enabled, the ECLAIR menu will change to include a disable option together with a number of navigation options described below.

We now assume that an IDE or editor is installed, ECLAIR is enabled and that a browser window containing ECLAIR reports is open.

The browser window that has had the most recent interaction with the IDE or editor is called the driving browser window. It is important to understand the following points:

  • The perspective that is available under the IDE or editor is the one of the driving browser window. For instance, if you used the features described in Section HTML Outputs and, in particular, Section Common Features, to hide all information reports, you will not see them in the IDE or editor.

  • Only one IDE or editor can be enabled at any one given time. For instance, if you are using Eclipse and at some stage you choose the Enable option from the ECLAIR menu of Visual Studio Code, you will see that this action disabled Eclipse; if you later want to use Eclipse again, you have to manually re-enable it.

In order to visualize the reports in the IDE or editor, the web browser needs to be paired and should be open in a report or source file view (see Sections Selected Reports Pages and Source File Pages).

If the browser is correctly paired a small icon is shown in the browser tab title.

Then, by Ctrl+Click or Alt+Click (under Windows and Linux), or Cmd+Click (under macOS) with the mouse on any report area link or any point in a source code view, the user can direct the enabled IDE or editor to take control at exactly that position.

Similarly, holding Ctrl+Click or Alt+Click (under Windows and Linux), or Cmd+Click (under macOS) and then moving the mouse over any source code area the user can select the corresponding program text both in the browser and in the IDE or editor.

An alternative way to direct the IDE or editor to a report area is to use the Edit this area option of the icon shown near any main report area, in both report and source code views (see Sections Selected Reports Pages and Source File Pages).

The details of how the visualization is displayed depends on the enabled IDE or editor, however many aspects are common by design. The ECLAIR plugin menu will contain the following commands:

Disable

disables this IDE or editor (presumably because the user wants to enable a different IDE or editor).

Stop server

stops all running instances of eclair_report. The interaction with IDEs and editors makes use of a persistent eclair_report server; this covers in the best possible way the usual workflow whereby a user works on one project at a time, making changes, reanalyzing, browsing reports. The only way to stop the server, is to select this command of the ECLAIR menu: use it when switching to a different project or when you stop working on a project and you prefer not having an unused process running on your system.

Pair browser

open a page on the default browser to associate browser with IDE or editor (only if eclair_report server is remote).

First report

goes to the source code for the first report that was shown in the driving browser windows (the perspective of the driving browser window applies to this as well as the following commands).

Previous report

goes to the source code for the previous report.

Next report

goes to the source code for the following report.

Last report

goes to the source code for the last report.

Previous area

goes to the source code for the previous area of the current report.

Next area

goes to the source code for the next area of the current report.

Add tagging comment

adds a tagged comment covering the current report area: see Section Mark Locally and Justify for information on tagged comments.

Run

shows a list of possible Run action that you have set. If you click on an action, ECLAIR will call your custom script passing to it a .eca file containing all the information about the report, the violation, and the rule. For more details see Section Custom Get and Run actions in ECLAIR.

Get on browser

shows a list of possible Get action that you have set. If you click on an action, ECLAIR will download a .eca file containing all the information about the report, the violation, and the rule. For more details see Section Custom Get and Run actions in ECLAIR.

Include in browser selection

shows all the selections not matching the current report. Click on a selection to include in that selection the reports having the same fingerprint of the current report.

Exclude from browser selection

shows all the selections matching the current report. Click on a selection to exclude from that selection the reports having the same fingerprint of the current report.

How to reach the plugin settings panel may differ between the IDEs (read the section dedicated to your IDE).

Build and Visualization from Inside the IDE or the Editor

In this scenario, the build is controlled from within the IDE or the editor. This involves scripting that is dependent on the actual IDE or editor, whose specificities will be treated in the dedicated sections later in this chapter.

The visualization of the reports is as explained in the previous section, with the added benefit of being able to directly perform incremental builds after editing the sources.

All ECLAIR Work Done on the Server

This scheme is the opposite of the one described in Section All ECLAIR Software Runs on the User’s Desktop and comes with dual advantages:

  1. the server is typically a very powerful machine and the user’s PC resources will not be involved;

  2. ordinary users do not need to be able to operate ECLAIR configuration and execution: only the person setting up the server needs to be competent on these aspects of ECLAIR.

Disadvantages are also dual:

  1. a license allowing the generation of detailed outputs in HTML format is required;

  2. the user has no control of the analysis configuration (this is not really a disadvantage in strictly-controlled environments) and execution and can only peruse the resulting detailed outputs.

In order to set up such a scheme, suitable scripting should be developed that performs the analysis upon a given triggering condition (e.g., continuously, every hour, upon a condition based on the version-control system in use). The script should terminate with the generation of HTML outputs as described in Section Producing HTML Outputs and their publication on a web site that is reachable from the local area networks that are compatible with the ECLAIR license.

Faster ECLAIR Analyses on the User’s Desktop, the Others on the Server

This scenario mixes the one presented in Section All ECLAIR Software Runs on the User’s Desktop and the one presented in Section All ECLAIR Work Done on the Server in order to obtain the best of both worlds.

The user would run ECLAIR on the PC, performing incremental analyses that only enable single translation unit checkers. In the most common case the user is working at a specific translation unit, so that a reanalysis will only involve that translation unit and be quite fast.

Full project analyses will be run on the integration server, where all the work done by individual developers is committed. Perusal of the reports generated by such full analyses can take place as described in Section All ECLAIR Work Done on the Server.

Of course, this scenario requires equipping both the user’s PC and the integration server with suitable ECLAIR license keys.

Integrating ECLAIR with Eclipse-Based IDEs

This section is for anyone who uses an IDE based on Eclipse for C/C++ and now needs to know how to use ECLAIR from within that IDE. These instructions have been tested on many Eclipse-based IDEs going back to 2010 and even before.

Installation and Basic Configuration

Installing the ECLAIR Eclipse plugin is done in a very similar way for all Eclipse-based IDEs. We devote a section to each of the main ones.

How to reach the plugin settings panel may differ between the IDEs (read the section dedicated to your IDE), but the settings are still the same. Under that you will find:

  • a field named Command to run eclair_report to be filled with the path of eclair_report;

  • a field named Arguments for eclair_report that allows you to provide to eclair_report additional options and arguments;

  • a field named ECLAIR report server host that allows you to provide the server host where eclair_report is running. By default the value is localhost;

  • a field named Use local ECLAIR report as proxy to be enabled if (and only if) the Eclipse is on a remote machine without an ECLAIR site license. When this option is enabled you need to execute eclair_report -server, e.g., by invoking it from a command line;

  • a field named Force https for ECLAIR report server connection to be enabled if (and only if) eclair_report server should use only HTTPS protocol;

  • a field named Project root directory that allows you to specify the project root path. Leave it empty if the value should be the one provided by the server;

  • a field named Message area tagging that allows you to specify the pattern of the message that will be inserted using the Tagging comment feature (see Selected Reports Pages).

In case the correct version of eclair_report is not the one that is selected via the PATH environment variable, fill the Command to run eclair_report field in the settings panel with the absolute path of the correct version of eclair_report. How to reach the plugin settings panel may differ between the IDEs, read the section dedicated to your IDE.

Arm Development Studio

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

CodeWarrior Development Studio

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); once that is done, select ECLAIR plugin, then click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish, and finally click on Yes when requested to restart CodeWarrior Development Studio in order to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

CrossCore Embedded Studio

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click OK; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

Eclipse IDE for C/C++ Developers from the Eclipse Foundation

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

HighTec Development Platform

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

MCUXpresso IDE

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the MCUXpresso IDE menu by selecting Preferences…, then choose ECLAIR in the left navigation panel.

QNX Momentics Tool Suite

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Momentics menu by selecting Preferences…, then choose ECLAIR in the left navigation panel.

Renesas e2 studio

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click OK; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

SiFive Freedom Studio

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

Silicon Labs Simplicity Studio

In order to install the ECLAIR Eclipse plugin, type the Ctrl+3 key combination when the Simplicity Studio main window has focus and start typing Install New Software… until you can select it. Then click on Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click OK; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

STM32CubeIDE

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

TASKING TriCore Eclipse IDE

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

Texas Intruments Code Composer Studio

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

Xilinx Vitis IDE

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Help menu by clicking on Install New Software…, choose Manage…, then choose ECLAIR in the left navigation panel.

DAVE (Infineon)

In order to install the ECLAIR Eclipse plugin, from the Help menu choose Install New Software…, then Add…, then Archive…, then select

PREFIX/eclair-VERSION/share/eclipse/eclair.zip

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Add; once that is done, select ECLAIR plugin, click Next twice, review the license agreement and accept its terms if you wish to continue, click Finish and then click Restart Now to conclude the installation.

You can reach the ECLAIR plugin settings from the Window menu by selecting Preferences, then choose ECLAIR in the left navigation panel.

Visualizing and Editing

Assuming that a browser window containing ECLAIR reports is open and ECLAIR is enabled as detailed in External Build, Visualization Inside the IDE or the Editor, the main region of Eclipse will contain the selected source code. If ECLAIR is selected in the control bar for the lower region, this region will contain the report message. Source code can now be edited and the changes saved in the usual way.

Note that if the code is not syntactically present in the source file, the report area will be labelled as <preprocessed ...> and the IDE will block any attempts to edit the code, displaying the Read-Only message in the bottom bar.

Running ECLAIR Analysis from within the IDE

Sample scripting for running the ECLAIR analysis from within an Eclipse-based IDE can be found in the corresponding Windows and Linux demos ECLAIR-MAJ_MIN_demo_crc_Windows_GCC_Eclipse_CDT and ECLAIR-MAJ_MIN_demo_crc_Linux_GCC_Eclipse_CDT.

where MAJ_MIN is the major and minor version numbers of ECLAIR separated by a dot (it corresponds to the complete version number by removing the final patch number).

For further information about the demo projects see chapter ECLAIR Demo Projects of the ECLAIR Evaluation Guide.

The most important file in the demos is README.txt, which explains how to proceed.

In essence, for each of the project existing configurations that should undergo static analysis, two new configurations must be added. For simplicity, let us suppose that there is just one existing project configuration. Then the sample scripting can be used to build two new configurations, called, e.g.,

ECLAIR

runs an incremental analysis (that is, only what is compiled/linked is analyzed) of the existing configuration;

ECLAIR_STU

as above, but only analyzing with respect to guidelines supported by single translation unit checkers to reduce analysis time;

ECLAIR_FINAL

as ECLAIR, but this also generates textual reports;

ECLAIR_FILE

runs an analysis of the currently opened file.

See Sections All ECLAIR Software Runs on the User’s Desktop and Faster ECLAIR Analyses on the User’s Desktop, the Others on the Server to understand in which scenarios the second configuration is interesting.

Integrating ECLAIR with Netbeans-Based IDEs

This section is for anyone who uses an IDE based on Netbeans and now needs to know how to use ECLAIR from within that IDE. These instructions have been tested on NetBeans 14 and MPLABX v6.00.

Installation and Basic Configuration

Installing the ECLAIR Netbeans plugin is done in a very similar way for all NetBeans-based IDEs. We devote a section to each of the main ones.

How to reach the plugin settings panel may differ between the IDEs (read the section dedicated to your IDE), but the settings are still the same. Under that you will find:

  • a field named Command to run eclair_report to be filled with the path of eclair_report;

  • a field named Arguments for eclair_report that allows you to provide to eclair_report additional options and arguments;

  • a field named ECLAIR report server host that allows you to provide the server host where eclair_report is running. By default the value is localhost;

  • a field named Use local ECLAIR report as proxy to be enabled if (and only if) the IDE is on a remote machine without an ECLAIR site license. When this option is enabled you need to execute eclair_report -server, e.g., by invoking it from a command line;

  • a field named Force https for ECLAIR report server connection to be enabled if (and only if) eclair_report server should use only HTTPS protocol;

  • a field named Project root directory that allows you to specify the project root path. Leave it empty if the value should be the one provided by the server;

  • a field named Message area tagging that allows you to specify the pattern of the message that will be inserted using the Tagging comment feature (see Selected Reports Pages).

In case the correct version of eclair_report is not the one that is selected via the PATH environment variable, fill the Command to run eclair_report field in the settings panel with the absolute path of the correct version of eclair_report. How to reach the plugin settings panel may differ between the IDEs, read the section dedicated to your IDE.

NetBeans IDE

In order to install the ECLAIR plugin, from the Tools menu in the top menu bar, choose Plugins, then open the Downloaded tab, then click on Add Plugins, then select

PREFIX/eclair-VERSION/share/netbeans/eclair-plugin-VERSION-netbeans.nbm

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Open; once that is done, select ECLAIR plugin, click Install and follow the installation wizard.

The plugin may be shown as self-signed, but the signature is available by selecting the Show details button after expanding the self-signed node and selecting the plugin’s name.

You can reach the ECLAIR plugin settings from the Tools menu by selecting Options, then choose ECLAIR in the top navigation panel.

MPLAB X IDE

In order to install the ECLAIR plugin, from the Tools menu in the top menu bar, choose Plugins, then open the Downloaded tab, then click on Add Plugins, then select

PREFIX/eclair-VERSION/share/netbeans/eclair-plugin-VERSION-mplabx.nbm

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); then click Open; once that is done, select ECLAIR plugin, click Install and follow the installation wizard.

The plugin may be shown as not signed, but the signature can be verified by running the command jarsigner --verify eclair-plugin-3.14.0-mplabx.nbm.

You can reach the ECLAIR plugin settings from the Tools menu by selecting Options, then choose ECLAIR in the top navigation panel.

Usage

A new ECLAIR menu will appear in the top menu bar of the IDE, and an ECLAIR tab in the Output window is created. When the user selects Enable a new tab titled ECLAIR will open (if not, it can be opened by clicking on Window->ReportView). When a report is selected from the browser, it will appear inside this window.

Assuming that a browser window containing ECLAIR reports is open and ECLAIR is enabled as detailed in External Build, Visualization Inside the IDE or the Editor, the main region of NetBeans will contain the selected source code. If ECLAIR is selected in the control bar for the lower region, this region will contain the report message. Source code can now be edited and the changes saved in the usual way.

Note that if the code is not syntactically present in the source file, the report area will be labelled as <preprocessed ...> and the IDE will block any attempts to edit the code.

All actions except Add tagging comment, Run and Get on browser can be associated with a keybining by setting entries in the Tools->Options->Keymap settings page. All ECLAIR options are under the ECLAIR and ECLAIR/AreaNode categories.

Running ECLAIR Analysis from within MPLABX

Sample scripting for running the ECLAIR analysis from within MPLABX IDE can be found in the corresponding Windows and Linux demos ECLAIR-MAJ_MIN_demo_crc_Windows_XC32_MPLABX and ECLAIR-MAJ_MIN_demo_crc_Linux_XC32_MPLABX.

where MAJ_MIN is the major and minor version numbers of ECLAIR separated by a dot (it corresponds to the complete version number by removing the final patch number).

For further information about the demo projects see chapter ECLAIR Demo Projects of the ECLAIR Evaluation Guide.

The most important file in the demos is README.txt, which explains how to proceed.

Select the ECLAIR Tasks entry on the project tree panel, and then double-click on one of the four available tasks:

ECLAIR_FULL

runs an incremental analysis (that is, only what is compiled/linked is analyzed) of the existing configuration;

ECLAIR_STU

as above, but only analyzing with respect to guidelines supported by single translation unit checkers to reduce analysis time;

ECLAIR_FINAL

as ECLAIR_FULL, but this also generates textual reports;

ECLAIR_FILE

runs an analysis of the currently opened file.

The task logs will be displayed on the Output windows under the Scripting tab.

See Sections All ECLAIR Software Runs on the User’s Desktop and Faster ECLAIR Analyses on the User’s Desktop, the Others on the Server to understand in which scenarios the second configuration is interesting.

Additional notes

  • When navigating a report, if the currently selected area’s text is not displayed in the editor, then double click on that area to update the view.

  • An additional restart of the IDE may be needed when installing or uninstalling the plugin.

Integrating ECLAIR with IDEs based on the IntelliJ Platform

This section is for anyone who uses an IDE based on the IntelliJ Platform and now needs to know how to use ECLAIR from within that IDE. These instructions have been tested on IntelliJ IDEA 2022.2.3 (Community Edition), CLion 2021.3.4 and Android Studio 2022.2.1.

Installation and Basic Configuration

Installing the ECLAIR IntelliJ plugin is done in a very similar way for all IDEs based on the IntelliJ Platform.

In order to install the ECLAIR plugin, select the File menu in the top menu and bar choose Settings, then open the Plugins tab on the left side, click on the gear icon next to the Installed tab and select Install Plugin from Disk. Select the file

PREFIX/eclair-VERSION/share/intellij/eclair-plugin-VERSION-VARIANT.jar

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); VARIANT is the variant of the plugin to select depending on IntelliJ Platform version of the IDE (IC-2023.1-or-later or IC-2022.3-or-earlier).

A new ECLAIR menu will appear in the top menu bar of the IDE, and a new tool window titled ECLAIR will appear in the bottom bar of the IDE (next to other tool windows, such as Problems or Terminal); if the component is not shown or has been hidden by mistake, enable it from View->Tool Windows->ECLAIR. Installing the plugin will add a new status bar component as well, showing whether the plugin is connected to a report server. The visibility of such a component can be toggled by selecting ECLAIR status from the View->Appearance->Status Bar Widgets menu.

The ECLAIR plugin settings can be reached from the ECLAIR menu in the top menu bar, by selecting the Settings item, or by clicking on the status bar widget.

Under that you will find:

  • a field named Command to run eclair_report to be filled with the path of eclair_report;

  • a field named Arguments for eclair_report that allows you to provide to eclair_report additional options and arguments;

  • a field named ECLAIR report server host that allows you to provide the server host where eclair_report is running. By default the value is localhost;

  • a field named Use local ECLAIR report as proxy to be enabled if (and only if) the IDE is on a remote machine without an ECLAIR site license. When this option is enabled you need to execute eclair_report -server, e.g., by invoking it from a command line;

  • a field named Force https for ECLAIR report server connection to be enabled if (and only if) eclair_report server should use only HTTPS protocol;

  • a field named Project root directory that allows you to specify the project root path. Leave it empty if the value should be the one provided by the server;

  • a field named Message area tagging that allows you to specify the pattern of the message that will be inserted using the Tagging comment feature (see Selected Reports Pages).

In case the correct version of eclair_report is not the one that is selected via the PATH environment variable, fill the Command to run eclair_report field in the settings panel with the absolute path of the correct version of eclair_report.

Any modification to the plugin settings is applied only to the current project, so it is recommended to check them before enabling the plugin.

Usage

Assuming that a browser window containing ECLAIR reports is open and the ECLAIR tool window is visible in the bottom bar of the IDE, the plugin functionality can be activated by selecting the ECLAIR->Enable action and wait for the status bar to show ECLAIR ONLINE. Selecting a report from the browser as detailed in External Build, Visualization Inside the IDE or the Editor will cause the IDE to open an editor tab containing the relevant source code. Source code can now be edited and the changes saved in the usual way.

Note that if the code is not syntactically present in the source file, the file will be labelled as <...> and the IDE will block any attempts to edit the code, such as adding a tagging comment. The same holds for files not present in the machine running the IDE; in that case, they will be labelled as @....

The tool window contains two content tabs: one showing the plugin log, and a panel showing a list of available actions of the left side, as well as a tree containing the currently selected report and its areas. If no report has been selected, the panel will be empty.

If the ECLAIR->Enable action fails, check the plugin log in the ECLAIR tool window to see the error message.

Keybindings can be associated to any action defined by the plugin. To do so, open the File->Settings->Keymap panel, and select Main Menu->ECLAIR from the tree; new bindings can be defined by right-clicking on the desired item. Be aware that the Add tagging comment, Run, Get on browser, Include in browser selection and Exclude from browser selection menus will be populated dynamically by defining the corresponding entities in the browser.

Running ECLAIR Analysis from within IDEs based on the IntelliJ Platform

Sample scripting for running the ECLAIR analysis from within IntelliJ IDE can be found in the corresponding Linux demos ECLAIR-MAJ_MIN_demo_crc_Linux_GCC_CLion.

where MAJ_MIN is the major and minor version numbers of ECLAIR separated by a dot (it corresponds to the complete version number by removing the final patch number).

For further information about the demo projects see chapter ECLAIR Demo Projects of the ECLAIR Evaluation Guide.

The most important file in the demos is README.txt, which explains how to proceed.

Once the project has been set up, you can launch the following tasks from the menu Tools->ECLAIR Tools

ECLAIR_FULL

runs an incremental analysis (that is, only what is compiled/linked is analyzed) of the existing configuration;

ECLAIR_STU

as above, but only analyzing with respect to guidelines supported by single translation unit checkers to reduce analysis time;

ECLAIR_FINAL

as ECLAIR_FULL, but this also generates textual reports;

ECLAIR_FILE

runs an analysis of the currently opened file.

The task logs will be displayed in a tab inside the Run tool window at the bottom of the screen.

See Sections All ECLAIR Software Runs on the User’s Desktop and Faster ECLAIR Analyses on the User’s Desktop, the Others on the Server to understand in which scenarios the second configuration is interesting.

Additional notes

  • If more than one IDE window is opened on different projects, the plugin can be used indipendently in each window, given that the target eclair_report server host is different (e.g. eclairit.com and localhost).

  • The plugin will be automatically disabled when its settings are changed

Integrating ECLAIR with Visual Studio

This section is for anyone who uses Visual Studio 2017, Visual Studio 2019 or Visual Studio 2022 and now needs to know how to use ECLAIR from within that IDE.

Installation and Basic Configuration

In order to install the ECLAIR Visual Studio plugin: if you are using Visual Studio 2017 and Visual Studio 2019 double click on

PREFIX/eclair-VERSION/share/visualstudio/Eclair-VS17.vsix

if you are using Visual Studio 2022 double click on

PREFIX/eclair-VERSION/share/visualstudio/Eclair-VS22.vsix

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); Select the Visual Studio versions in which you want to install the plugin, then choose Install.

To reach the plugin settings page click on the Tools menu select Options…, then click on ECLAIR in the left panel. You will find:

  • a field named Eclair report command to be filled with the path of eclair_report. Here you can also add any additional options and argument to eclair_report;

  • a field named Eclair report command arguments to be filled with a list of arguments and options for eclair_report.

  • a field named ECLAIR report host that allows you to provide the server host where eclair_report is running. By default the value is localhost;

  • a field named Force SSL to be enabled if (and only if) eclair_report server should use only HTTPS protocol;

  • a field named Project root that allows you to specify the project root path. Leave it empty if the value should be the one provided by the server;

  • a field named Tag area message that allows you to specify the pattern of the message that will be inserted using the Tagging comment feature (see Selected Reports Pages);

  • a field named Use proxy to be enabled if (and only if) Visual Studio is on a remote machine without an ECLAIR site license. When this option is enabled you need to execute eclair_report -server, e.g., by invoking it from a command line.

In case the correct version of eclair_report is not the one that is selected via the PATH environment variable, fill the Eclair Report Command field with the absolute path of the correct version of eclair_report.

Visualizing and Editing

Assuming that a browser window containing ECLAIR reports is open and ECLAIR is enabled as detailed in External Build, Visualization Inside the IDE or the Editor, the main section of Visual Studio will contain the selected source code. If ECLAIR is selected in the control bar for the lower section, this section will contain the report message. Source code can now be edited and all changes can be saved in the usual way.

Note that if the code is not syntactically present in the source file, the report area will be labelled as <preprocessed ...> and the IDE will block any attempts to edit the code.

Integrating ECLAIR with Visual Studio Code

This section is for anyone who uses Visual Studio Code for C/C++ and now needs to know how to use ECLAIR from within the editor.

Installation and Basic Configuration

In order to install the ECLAIR Visual Studio (VS) Code plugin, you should bring up the Extensions view. There are three ways of doing that:

  1. Clicking on the Extensions icon in the activity bar on the left-hand side of VS Code

    _images/vs-code-extensions-view-icon.png
  2. Typing the key combination Ctrl Shift X.

  3. From the File menu, choosing Preferences, then Extensions.

Once in the Extensions view, click on the icon on its top-right corner and select Install from VSIX…, then direct the file browser to

PREFIX/eclair-VERSION/share/vscode/eclair-X.Y.Z.vsix

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation), whereas X.Y.Z is the version number of ECLAIR VS Code plugin. Once that file is selected, click on Install. Installation will try to connect to an existing eclair_report server: if none exist an error message will be displayed, which can be safely ignored. In any case, the installation process should result into the appearance of ECLAIR X.Y.Z followed by BUGSENG in the Extensions view and in the display of the following message in the bottom-right corner of VS Code’s window: Completed installing the extension ECLAIR.

To reach the plugin settings page click on the Manage gear button to the right of BUGSENG in the Extensions view, then choose Extension Settings. You will find:

  • a field named Eclair Report Command to be filled with the path of eclair_report. Here you can also add any additional options and argument to eclair_report;

  • a field named ECLAIR Report Host that allow you to provide the server host where eclair_report is running. By default the value is localhost;

  • a field named Proxy to be enabled if (and only if) Visual Studio Code is on a remote machine without an ECLAIR site license. When this option is enabled you need to execute eclair_report -server, e.g., by invoking it from a command line;

  • a field named Force SSL to be enabled if (and only if) eclair_report server should use only HTTPS protocol;

  • a field named Project Root that allow you to specify the project root path. Leave it empty if the value should be the one provided by the server;

  • a field named Tag Area Message that allow you to specify the pattern of the message that will be inserted using the Tagging comment feature (see Selected Reports Pages).

In case the correct version of eclair_report is not the one that is selected via the PATH environment variable, fill the Eclair Report Command field with the absolute path of the correct version of eclair_report.

Visualizing and Editing

Assuming that a browser window containing ECLAIR reports is open and ECLAIR is enabled as detailed in External Build, Visualization Inside the IDE or the Editor, the main region will contain the selected source code. If ECLAIR REPORT is selected in the control bar for the lower region, this region will contain the report message. Source code can now be edited and the changes saved in the usual way.

Note that if the code is not syntactically present in the source file, the report area will be labelled as <preprocessed ...> and the editor will block any attempts to edit the code, displaying the Cannot edit in read-only editor message in a pop-up window.

Running ECLAIR Analysis from within Visual Studio Code

Sample scripting for running the ECLAIR analysis from within VSCode can be found in the corresponding Windows and Linux demos ECLAIR-VERSION_demo_crc_Linux_GCC_VSCode and ECLAIR-VERSION_demo_crc_Windows_GCC_VSCode.

where MAJ_MIN is the major and minor version numbers of ECLAIR separated by a dot (it corresponds to the complete version number by removing the final patch number).

For further information about the demo projects see chapter ECLAIR Demo Projects of the ECLAIR Evaluation Guide.

The most important file in the demos is README.txt, which explains how to proceed.

Under Terminal on the window menu bar select Run Task or press F1 and select Task: Run Task. The menu shown will have 3 ECLAIR options:

ECLAIR prepare

selecting this prepares the project for the build;

ECLAIR build

selecting this after an edit does an incremental build of the project;

ECLAIR STU build

as above, but only analyzing with respect to guidelines supported by single translation unit checkers to reduce analysis time.

ECLAIR clean

selecting this cleans the project.

Integrating ECLAIR with Emacs

This section is for anyone who uses the emacs editor and now needs to know how to use ECLAIR from within emacs.

Installation and Basic Configuration

In order to install the ECLAIR Emacs plugin, you should load into Emacs

PREFIX/eclair-VERSION/share/emacs/eclair.elc

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation); The most convenient way for doing so is to include Emacs Lisp code like the following into the .emacs file located into your home directory:

;; Load the ECLAIR Emacs plugin.
(setq eclair_plugin_filename "/opt/bugseng/eclair/share/emacs/eclair.elc")
(if (file-exists-p eclair_plugin_filename)
    (load eclair_plugin_filename))

Then open Emacs in the usual way. There will now be an extra option ECLAIR in the window menu bar.

In case the correct version of eclair_report is not the one that is selected via the PATH environment variable, provide the correct path editing to Eclair Report Command in the plugin options.

To reach the plugin options click on the Options menu, select Customize Emacs and then Browse Customization Groups. If you expand the Eclair group, you will see:

  • an option named Eclair Report Command to be filled with the path of eclair_report and an optional list arguments;

  • an option named ECLAIR Host that allow you to provide the server host where eclair_report is running. By default the value is localhost;

  • an option named Eclair Proxy to be enabled if (and only if) Emacs is on a remote machine without an ECLAIR site license. When this option is enabled you need to execute eclair_report -server, e.g., by invoking it from a command line;

  • an option named Eclair Force Ssl to be enabled if (and only if) eclair_report server should use only HTTPS protocol;

  • an option named Eclair Preview where you can enable or disable area preview on mouse over;

  • an option named Eclair Project Root that allow you to specify the project root path. Leave it empty if the value should be the one provided by the server;

  • an option named Eclair Tag Format that allow you to specify the pattern of the message that will be inserted using the Tagging comment feature (see Selected Reports Pages).

  • an option named Eclair Mode where you can enable or disable the ECLAIR menu;

  • a series of graphical options.

Visualizing and Editing

Assuming that a browser window containing ECLAIR reports is open and emacs is enabled as detailed in External Build, Visualization Inside the IDE or the Editor, two emacs windows will open: one containing the report message and the other containing the source code. Source code can now be edited and the changes saved in the usual way.

Note that if the code is not syntactically present in the source file, the report area will be labelled as <preprocessed ...> and emacs will block any attempts to edit the code, indicating in the minibuffer region Buffer is read only.

Integrating ECLAIR with Jenkins

This section is for anyone who uses Jenkins and needs to know how to integrate ECLAIR with Jenkins. This will allow quickly finding the changes that caused a certain violation, obtaining some statistical information about reports over time and so on. We assume the reader is familiar with Jenkins.

The ECLAIR Jenkins plugin relies on Warning Next Generation Plugin: here we will describe only the features related to the ECLAIR Jenkins plugin: the reader is referred to Warning Next Generation Plugin full documentation for more details.

Due to some limitations of the Warning Next Generation Plugin the plugin can efficiently handle projects with a limited number of violations.

We suggest using the plugin only if the project contains reports in the order of tens of thousands, for bigger databases we suggest using the general solution proposed in Integrating ECLAIR with Services for Software Development and CI.

A small demonstration of some ECLAIR capabilities when used from within Jenkins can be found in the corresponding Windows and Linux demos ECLAIR-MAJ_MIN_demo_crc_Windows_Jenkins_GCC and ECLAIR-MAJ_MIN_demo_crc_Unix_MC3_GCC_Jenkins.

where MAJ_MIN is the major and minor version numbers of ECLAIR separated by a dot (it corresponds to the complete version number by removing the final patch number).

For further information about the demo projects see chapter ECLAIR Demo Projects of the ECLAIR Evaluation Guide.

The most important file in the demos is README.txt, which explains how to proceed.

Installation and Global Configuration

To install the ECLAIR Jenkins plugin, from the Plugin Manager page choose Advanced…, then under Upload Plugin select

PREFIX/eclair-VERSION/share/jenkins/eclair-JenkinsJENKINS_VERSION.hpi

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation). JENKINS_VERSION is the Jenkins version: for example 2.3 is for Jenkins versions from 2.3XX.Y to 2.4XX.Y excluded, while 2.4 for Jenkins versions starting from from 2.4XX.Y.

Click the Upload button and, once installation is done, restart Jenkins.

Once you have installed the plugin you need to setup it, so from the Manage Jenkins page, choose Configure System and locate a section named ECLAIR.

Under that you will find:

  • a field named ECLAIR server ownership to be enabled if (and only if) the eclair_report server needs to be launched and managed by Jenkins;

  • a field named ECLAIR report command to be filled with the path of eclair_report or left empty if you have already added the directory which contains the file to Jenkins PATH (which you can do via Manage Jenkins, Configure System, Global properties, Environment variables);

  • a field named ECLAIR report command additional args that allow you to provide to eclair_report additional options and arguments;

  • a field named Use ECLAIR report proxy mode to be enabled if (and only if) the Jenkins server is on a remote machine without an ECLAIR site license. When this option is enabled you need to execute eclair_report -server, e.g., by invoking it from a command line;

  • a field named Use ECLAIR SSL mode to be enabled if (and only if) eclair_report server should use only HTTPS protocol;

  • a field named ECLAIR SSL certificate path to be filled if ECLAIR server ownership and Use ECLAIR SSL Mode are enabled, to specify the certificate file path for the eclair_report server. The default certificate is in PREFIX/eclair-VERSION/lib/ssl/eclair_report.pem;

  • a field named Allow ECLAIR actions be enabled only if you want to force eclair_report server launched by Jenkins to be administered by remote clients. (relevant only if ECLAIR server ownership is enabled).

Job Configuration

We assume that you already have an analysis script with which you run ECLAIR on your project and builds the corresponding ECLAIR database. To this you should add the generation of the Jenkins report file using -reports_jenkins.

On Windows, the resulting script might have the following form:

analyze.bat
 1@echo off
 2setlocal EnableDelayedExpansion
 3rem Absolute path of the ECLAIR bin directory.
 4set ECLAIR_BIN_DIR=C:\Program Files\BUGSENG\eclair-3.14.0\bin
 5
 6rem Directory where this script resides: usually in a directory named "ECLAIR".
 7set SCRIPT_DIR=%~dp0
 8rem Directory where to put all ECLAIR output and temporary files.
 9set ECLAIR_OUTPUT_DIR=%SCRIPT_DIR%out
10
11rem Absolute path of the toolchain bin directory.
12set TOOLCHAIN_BIN_DIR=C:\Program Files\gcc-arm-none-eabi-8-2018-q4-major\bin
13rem Absolute paths of toolchain components that ECLAIR should intercept.
14set CC_ALIASES="%TOOLCHAIN_BIN_DIR%/arm-none-eabi-gcc.exe"
15set CXX_ALIASES="%TOOLCHAIN_BIN_DIR%/arm-none-eabi-g++.exe"
16set AS_ALIASES="%TOOLCHAIN_BIN_DIR%/arm-none-eabi-as.exe"
17set AR_ALIASES="%TOOLCHAIN_BIN_DIR%/arm-none-eabi-ar.exe"
18set LD_ALIASES="%TOOLCHAIN_BIN_DIR%/arm-none-eabi-ld.exe"
19
20rem ECLAIR workspace.
21set ECLAIR_WORKSPACE=%ECLAIR_OUTPUT_DIR%\eclair_workspace
22rem Destination file for the ECLAIR diagnostics.
23set ECLAIR_DIAGNOSTICS_OUTPUT=%ECLAIR_OUTPUT_DIR%\DIAGNOSTICS.txt
24rem ECLAIR binary data directory and project database.
25set ECLAIR_DATA_DIR=%ECLAIR_OUTPUT_DIR%\.data
26
27rem Identifies the particular build of the project.
28set ECLAIR_PROJECT_NAME=MyProject_Release
29rem All paths mentioned in ECLAIR reports that are below this directory
30rem will be presented as relative to ECLAIR_PROJECT_ROOT.
31set PARENT_DIR=%SCRIPT_DIR%..
32set ECLAIR_PROJECT_ROOT=%PARENT_DIR%\MyProject
33
34rem Erase and recreate the output directory and the data directory.
35rd /s /q "%ECLAIR_OUTPUT_DIR%" 2>nul
36md "%ECLAIR_DATA_DIR%" || exit /b
37
38rem Clean the build, so that the project will be rebuilt from scratch.
39pushd "%ECLAIR_PROJECT_ROOT%\build\Release"
40make clean || exit /b
41
42rem Perform the build (from scratch) in an ECLAIR environment.
43"%ECLAIR_BIN_DIR%\eclair_env" "-eval_file='%SCRIPT_DIR:\=\\%analysis.ecl'" ^
44                              -- make || exit /b
45popd
46
47rem Create the project database.
48set PROJECT_ECD=%ECLAIR_DATA_DIR%\PROJECT.ecd
49"%ECLAIR_BIN_DIR%\eclair_report" "-create_db='%PROJECT_ECD:\=\\%'" ^
50        "%ECLAIR_DATA_DIR:\=\\%\\FRAME.*.ecb" ^
51        -load || exit /b
52
53rem Create the Jenkins reports file.
54set JENKINS_XML=%SCRIPT_DIR%\jenkins.xml
55"%ECLAIR_BIN_DIR%\eclair_report" "-db='%PROJECT_ECD:\=\\%'" ^
56        "-reports_jenkins='%JENKINS_XML:\=\\%'" || exit /b
57endlocal

On Linux, the resulting script might have the following form:

analyze.sh
 1#!/bin/bash
 2# Stop immediately if any executed command has exit status different from 0.
 3set -e
 4
 5# Absolute path of the ECLAIR bin directory.
 6ECLAIR_BIN_DIR="/opt/bugseng/eclair-3.14.0/bin"
 7
 8# Directory where this script resides: usually in a directory named "ECLAIR".
 9SCRIPT_DIR="$(cd "$(dirname $0)" ; echo ${PWD})"
10# Directory where to put all ECLAIR output and temporary files.
11ECLAIR_OUTPUT_DIR="${SCRIPT_DIR}/out"
12
13# Absolute path of the toolchain bin directory.
14TOOLCHAIN_BIN_DIR="/opt/gcc-arm-none-eabi-8-2018-q4-major/bin"
15# Absolute paths of toolchain components that ECLAIR should intercept.
16export CC_ALIASES="\"${TOOLCHAIN_BIN_DIR}/arm-none-eabi-gcc\""
17export CXX_ALIASES="\"${TOOLCHAIN_BIN_DIR}/arm-none-eabi-g++\""
18export AS_ALIASES="\"${TOOLCHAIN_BIN_DIR}/arm-none-eabi-as\""
19export AR_ALIASES="\"${TOOLCHAIN_BIN_DIR}/arm-none-eabi-ar\""
20export LD_ALIASES="\"${TOOLCHAIN_BIN_DIR}/arm-none-eabi-ld\""
21
22# ECLAIR workspace.
23export ECLAIR_WORKSPACE="${ECLAIR_OUTPUT_DIR}/eclair_workspace"
24# Destination file for the ECLAIR diagnostics.
25export ECLAIR_DIAGNOSTICS_OUTPUT="${ECLAIR_OUTPUT_DIR}/DIAGNOSTICS.txt"
26# ECLAIR binary data directory and project database.
27export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data"
28
29# Identifies the particular build of the project.
30export ECLAIR_PROJECT_NAME="MyProject_Release"
31# All paths mentioned in ECLAIR reports that are below this directory
32# will be presented as relative to ECLAIR_PROJECT_ROOT.
33PARENT_DIR="$(dirname "${SCRIPT_DIR}")"
34export ECLAIR_PROJECT_ROOT="${PARENT_DIR}/MyProject"
35
36# Erase and recreate the output directory and the data directory.
37rm -rf "${ECLAIR_OUTPUT_DIR}"
38mkdir -p "${ECLAIR_DATA_DIR}"
39(
40    # Clean the build, so that the project will be rebuilt from scratch.
41    cd "${ECLAIR_PROJECT_ROOT}/build/Release"
42    make clean
43
44    # Perform the build (from scratch) in an ECLAIR environment.
45    "${ECLAIR_BIN_DIR}/eclair_env" "-eval_file='${SCRIPT_DIR}/analysis.ecl'" \
46                                   -- make
47)
48# Create the project database.
49PROJECT_ECD="${ECLAIR_DATA_DIR}/PROJECT.ecd"
50"${ECLAIR_BIN_DIR}/eclair_report" "-create_db='${PROJECT_ECD}'" \
51                                  "${ECLAIR_DATA_DIR}"/FRAME.*.ecb \
52                                  -load
53
54# Create the Jenkins reports file.
55JENKINS_XML="${SCRIPT_DIR}/jenkins.xml"
56"${ECLAIR_BIN_DIR}/eclair_report" "-db='${PROJECT_ECD}'" \
57                                  "-reports_jenkins='${JENKINS_XML}'"

Note that these are just examples: the only essential thing is that the script generates the ECLAIR database as described in Section The eclair_report Command and the corresponding Jenkins report file. Said that, we recommend the following:

  • place the analysis script in a directory named ECLAIR just under the project root;

  • generate the ECLAIR database and diagnostic output in a subdirectory of ECLAIR named out (as you will see we will configure Jenkins to archived this directory);

  • generate the Jenkins report file directly under ECLAIR (so it will not be archived: archiving it would be pointless).

If you decide to use the above scripts as a starting point, please make sure you adapt at least the highlighted lines to your use case.

In the sequel, assume that you have configured an ECLAIR job on Jenkins which produces an ECLAIR database and the Jenkins report file, and that you have tested that such machinery works as expected: there is no point in going forward until this is not the case.

These are the steps to be followed in order to adapt your ECLAIR job for using the ECLAIR Jenkins plugin:

  1. Add a Post-build Action called Archive the artifacts and select the path where the job writes the ECLAIR database.

  2. Add a Post-build Action called Record compiler warnings and static analysis results selecting ECLAIR on the Tool field.

  3. Fill the Report File Pattern with the relative path of the Jenkins reports file that is generated by analysis script (e.g., ECLAIR/jenkins.xml).

  4. If necessary, edit ECLAIR database path. If you have followed the above advice, you do not need to change the default ECLAIR/out/PROJECT.ecd otherwise it should be set to actual relative path of the ECLAIR database.

Usage

In a build page of a job configured for ECLAIR, the left-hand side panel will contain:

  • an ECLAIR Project Home link pointing to the eclair_report homepage of the reports database generated by the selected build (see Section HTML Outputs).

  • an ECLAIR Warnings link pointing to the page with the ECLAIR reports generated for the current build.

In ECLAIR Warnings, the second word is hard-coded in the Warning Next Generation Plugin. This a bit unfortunate, as not all ECLAIR reports are meant to convey warnings.

Note that, in order to browse the ECLAIR reports an eclair_report server must be running on the Jenkins machine. Enabling the option ECLAIR server ownership Jenkins will automatically start a new eclair_report server. If a server is already running, this will be killed. In addition, if the Jenkins server is on a remote machine without an ECLAIR site license, a locally running eclair_report server must be available and the ECLAIR report proxy must be enabled as described above.

When you are in the ECLAIR Warnings page of the build, in the Modules tab you will see the report counts by service, whereas in the Folders, Files, Categories, Types tab you will see the report counts by directories, files, categories and types respectively.

In the Issues tabs, if the license allows that, you can consult ECLAIR detailed reports clicking on file names will open a new browser tab on the named file, in the context of that report. Just hovering on the file name will display a preview area in the current browser tab, unless you disable Mouse over preview. Alternatively, if you enable Preview window, a new browser window will be opened, and previews will always be shown in that window. If your license does not allow you access to detailed reports, disabling both Mouse over preview and Preview window will spare you from seeing blank previews.

Running Pipelines Within a Docker Container

Running pipelines in a Docker container avoids the need for every user to have direct access to the CI/CD server and unifies the build and test environments across all machines.

Jenkins provides a very easy-to-use plugin and detailed documentation, see Using Docker with Pipeline.

ECLAIR, the toolchain and other dependencies should be installed during the pipeline or directly in the Docker image, see Running ECLAIR in Docker Containers.

Integrating ECLAIR with Services for Software Development and CI

This section is for anyone who uses an Internet hosting service for software development and continous integration like GitHub, GitLab and Jenkins.

In particular, for the GitHub, GitLab and Jenkins platforms, we provide all the required files and instructions to:

  • create an automatic analysis that runs at every push on a specific branch;

  • create an automatic analysis that runs at every push on the source branch of a pull-request (not applicable for Jenkins);

  • create a manual analysis that generates several artifacts in various formats;

  • collect and show the analysis results on an informative page provided by a customizable web server handled by eclair_report. The web server also allows the navigation of the analysis results and provides counts of both fixed and new reports compared to the previous analysis;

  • publish comments on the pull-request and commit threads with useful information about the analysis (not applicable for Jenkins);

  • provide detailed logging about the analysis.

Please note that pull-request is a GitHub-specific term, the equivalent concept in GitLab is merge-request. In the context of this section, we will generally use the first term.

Please note that runner is a GitHub and GitLab-specific term, the equivalent concept in Jenkins is agent. In the context of this section, we will generally use the first term.

We assume the reader is familiar with git and the CI/CD system provided by the chosen service.

Generally, every service with CI/CD possibilities has some concept of user-defined tasks that usually can be defined by means of a special platform-dependent syntax and triggered by a wide range of events on the underlying repository or on the platform itself. An example of the first one could be a push or a commit, for the second one a pull request or a click on a specific button.

As each service has its own name for these tasks (e.g. action in GitHub, pipeline in GitLab and Jenkins), for simplicity, we will use the term action.

Demo projects showing all the integration possibilities can be found in:

Note

For Jenkins an ad-hoc plugin is also provided (see Integrating ECLAIR with Jenkins). The plugin is a very powerful and ready-made solution and we definitely suggest using it to quickly integrate ECLAIR in your pipelines. The plugin can efficiently handle projects with a limited number of reports in the order of tens of thousands.

The current general solution is more flexible (it can be fully customized) and scalable (it can be used with very large projects), it provides a common platform for all CI/CD services.

Carefully choose whether to use the plugin or the current solution according your requirements and needs, in case of doubt, contact the ECLAIR support.

The two solutions cannot be used together.

Configuration of the integration

Configuring the provided integration depends on many aspects:

  • the specific CI/CD service in use;

  • the setup of the machines involved in the infrastructure;

  • eventual Dockerization of the CI/CD components;

  • other security/safety considerations.

For these reasons, providing a trivial step-by-step guide is not possible, but the following list can be considered as an overview of the operations required. Any operation will be fully explained in a dedicated section (that may be further expanded to discriminate the specific CI/CD service in use).

Setup of the CI/CD infrastructures:

for this first step, we assume that the CI/CD service has already been configured and the projects for which the ECLAIR tasks should be integrated are already configured and ready to use. Here is a quick overview of the components of the infrastructure:

  • the CI/CD server: this is the physical machine where the CI/CD service is running. It can be a self-hosted machine or not depending on the service and the customer’s needs;

  • the runner: this is the environment where the CI/CD tasks run. It could be a physical machine or a virtual environment (such as a Docker container). This machine requires a licensed installation of ECLAIR. See Installation of the Runner for further details;

  • the ext server: this is the machine where the artifacts are stored and from which the analysis results are provided. Since the feature of exposing the analysis results on a web interface is part of eclair_report, this machine requires a licensed installation of ECLAIR. By renouncing any remote navigation of the results, this component can be avoided. See The ext Web Server for further details.

Note that these components do not need to be on different machines and use of a common machine may lessen the required number of license keys.

Creation of the artifacts directory:

the artifacts directory is the location in the ext server where the artifacts of a specific project are stored. For each project, an artifacts directory (its name must end with .ecdf) must be created and the variable artifactsDir in the action.settings file should be amended with the correct path (see Action Settings).

Creation of the wtoken:

in the artifacts directory of any project a special wtoken file should be created. This file will be used to authenticate the operations in the directory. See Authentication to the ext server of the POST requests.

Upload the passphrase used to generate the wtoken:

create a masked variable (be sure that it is visible to the target project) named WTOKEN containing the passphrase used to generate the wtoken file. See Authentication to the ext server of the POST requests.

Creation of the impersonation/API token:

this operation is only required in GitLab and Jenkins if the creation of summary messages in the pipeline pages is enabled. In order to communicate with the GitLab/Jenkins API, the integration requires impersonating a platform user. We suggest creating an ad-hoc account with enough privileges on the target project and calling it, for example, ECLAIR. See Impersonation Token, API Token.

Enable Safe HTML formatter:

this operation is only required in Jenkins and if the creation of summary messages in the pipeline pages is enabled. The integration produces these reports in HTML format, this means that the Jenkins descriptions should be interpreted as HTML. See OWASP Markup Formatter.

Upload the impersonation token:

this operation is only required in GitLab. Once the impersonation token has been created, provide it to the integration. See Impersonation Token.

Start the ext server:

before running the actions, the ext server should be configured and started. See Start of the ext server.

Prepare the analysis scripts

prepare the scripts to run the analysis and to produce the desired artifacts. The following sections assume that an analyze.sh script that performs such operations is present in the repository. The script should ideally take an argument ANALYSIS_KIND to discriminate between the artifacts being produced, see Action push and Action pull_request.

Configure the actions:

copy and adapt the files for your platform in the repository to create the analysis actions. All the platform-independent operations required by the actions have been encapsulated in scripts documented in Action Scripts. The operation required to create the actions are platform-dependent, see the section dedicated to your platform: Creation of GitLab Pipelines, Creation of GitHub actions or Creation of Jenkins Pipelines.

Installation of the Runner

A runner is an application that runs the job contained in the actions that come from the CI/CD system.

Generally, a runner can be run:

  • on hosted virtual environments provided by the platform.

  • on self-hosted environments.

Since ECLAIR requires a license key to work, the choice between these two options is particularly delicate and depends on the type of license the user has. We suggest, whenever possible, using the second option and installing Sentinel and the license keys on the same machine where the jobs are executed.

The first option requires particular attention to the procedures to link the license key to the virtual environment.

For both options, the runner must satisfy the following requirements:

  • the software required to build the project is installed;

  • ECLAIR is installed;

  • a license key for ECLAIR is somehow available.

The installation is platform-dependent so, for this reason, follow the steps reported in the section dedicated to your platform:

Running Actions Within a Docker Container

Running actions within a Docker container is the best option as these platforms are generally intended for collaborative projects that may involve people from multiple companies. In such complex working contexts, where people from other businesses have access to the code (e.g., write permission on the repository) and are able to create actions and run code on your server, protecting the action is definitely recommended.

Leaving aside malicious intentions, non-expert users could crash the server making it unavailable for the next actions or, in the worse case, unintentionally modify configurations making the server unusable and requiring manual work by the system administrators.

In the particular context of ECLAIR, a very crucial point is how to provide the license. Several options are possible, see Running ECLAIR in Docker Containers.

Since running actions within a Docker container is platform-dependent, follow the steps reported in the section dedicated to your platform:

The ext Web Server

Internet versioning services like GitHub and GitLab provide limited capabilities in terms of representing the analysis results and it is definitely recommended that eclair_report is used for this.

Jenkins, instead, has a wide range of plugins and addons for this task. We provide an ad-hoc plugin for this purpose (see Integrating ECLAIR with Jenkins).

The ECLAIR plugin for Jenkins is definitely a very powerful and self-contained solution for integrating ECLAIR, but, due to intrinsic limitations of the platform, it cannot handle projects with hundreds of thousands of reports. For this reason, we suggest using the plugin only if the project contains a limited number of reports (in the order of tens of thousands).

The tool eclair_report can be used to handle a web server able to provide the analysis results and all the required summary information. Where the ext server is installed is up to the user, provided the machine is licensed for ECLAIR and exposed to the runners.

The interactions between the actions and the ext server are the following:

  • each database generated by an action is sent to the web server with other information about the action itself by means of a dedicated POST request.

  • the POST request is handled by the server. From the database, differential statistics such as the numbers of new/fixed/unfixed reports are extracted and static HTML pages with the information are generated. The ext server also links the previous and next action pages. The reports in the databases are also tagged with the information (see -diff_full_txt).

  • HTML pages and artifacts are stored. They can then be made available to any authorized CI/CD user. It is recommended links to these resources are placed in appropriate locations in the platform like commit and pull-request threads and README files.

A reference implementation of a node server with such capabilities can be found in:

PREFIX/eclair-VERSION/share/ci/ext

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation).

The server is written in TypeScript, but any language can be used. Correctly handling the requests defined in The ext Web Server APIs is the only requirement to be satisfied by any alternative implementation.

Note that the TypeScript files cannot be interpreted directly and must be converted to JavaScript. An already converted file is also provided. Since the server has been designed to be easily adapted to the customer’s needs, the rest of this section explains how the delivered JavaScript file was obtained.

The procedure requires Node.js to be installed; it can be downloaded from the Node.js website. Let SCRIPT_PATH be the directory path of the reference ext server mentioned above. The steps for the conversion are the following:

cd ${SCRIPT_PATH}
npm install
npm run build

Note

The ability to provide ECLAIR databases and files under directories ending with .ecdf is not related to the ext server, but it is always present in any eclair_report server.

Authentication to the ext server of the POST requests

Each POST request sent by an action needs to be authenticated by means of a special token. The token must be created with -htpasswd and then placed in the artifacts directory (.ecdf directory). The ext server will look for a file .wtokens in the artifacts directory and if the token matches the request will be authenticated.

Example:

# Ext server
cd /project_artifacts/PROJECT.ecdf
eclair_report -htpasswd=.wtokens,all,passphrase

Warning

Store the passphrase used to generate the token in an action variable named WTOKEN. The value of this variable should not appear in plain text inside logs; how to accomplish this depends on the CI/CD service in use. These are the recommended methods for GitLab, GitHub and Jenkins:

Authentication to the ext of CI/CD users to obtain resources

Each resource request (HTML pages, analysis results, etc …) from a CI/CD user to the ext server should be authenticated before being dispatched. eclair_report provides several mechanisms, see -auth.

Warning

If the eclair_report server is externally exposed, providing a strong authentication policy is recommended.

To discover the most appropriate authentication method to use with your CI/CD service, see the section dedicated to your platform:

Start of the ext server

After Node has been installed and the server file has been prepared, run the eclair_report server with the -server_ext and the most appropriate authentication method, see Authentication to the ext of CI/CD users to obtain resources:

eclair_report  -auth=... -server_ext={EXT_SOCKET},node,{SCRIPT_PATH}/ext.js,{EXT_SOCKET}

The first argument EXT_SOCKET is the pathname of the socket/named pipe file used by the ext server to communicate with eclair_report, then follows the command and the arguments to launch the server node SCRIPT_PATH/ext.js EXT_SOCKET. The socket/named pipe file should not be created manually, it will be generated by the ext server when required.

The ext Web Server APIs

The server APIs consist of two methods:

  • POST:/ext/update_push;

  • POST:/ext/update_pull_request.

The following arguments are common to both methods:

artifactsDir

is the directory in the ext server where the artifacts of the repository are to be stored. It must end with .ecdf otherwise the web server cannot provide the files, see -auth;

wtoken

is the authentication token. This token will be used to authenticate the user sending the request. The server will search for it in the .wtoken file in the artifactsDir. See Authentication to the ext server of the POST requests

subDir

is the subdirectory inside the artifactsDir where to store the files. It could be the branch name, some characteristic of the build or of the analysis (e.g. main_Debug, main_Release, develop_MC3, …).

jobId

is the identifier of the action job;

jobHeadline

is the headline used for the jobId/index.html page;

badgeLabel

is the badge label used for the jobId/badge.svg badge.

keepOldAnalyses

is the number of analyses stored by the ext server. Older analyses will be deleted. If set to 0 all analyses will be kept.;

autoPRRepository

is the target repository of the auto PR pull request. If autoPRBranch is defined, all commits from other branches or repositories will be considered pull-requests to autoPRBranch of autoPRRepository.

autoPRBranch

is the target branch of the auto PR pull request. If autoPRBranch is defined, all commits from other branches or repositories will be considered pull-requests to autoPRBranch of autoPRRepository.

db

is the ECLAIR database file.

POST:/ext/update_push has the following specific argument:

commitId

is the identifier of the base branch’s last commit;

POST:/ext/update_pull_request has the following specific argument:

baseCommitId

is the identifier of the most recent merge point in the source branch without conflicts;

After handling the requests, the artifacts directory will contain:

  • a commits directory containing symbolic links for each commit job directory;

  • a directory for each subDir, containing a directory for each job;

  • symbolic link to the last job.

Each job directory includes:

  • the provided database with the POST request;

  • a badge badge.svg with the analysis results;

  • a file fixedReports.txt containing the number of fixed reports;

  • a file index.html containing useful information about the job and the analysis. It includes also links to the previous and next job.

  • a file newReports.txt containing the number of new reports;

  • a file unfixedReprts.txt containing the number of fixed reports;

  • symbolic links for the next and previous job directories.

Since both methods perform write operations on the server, it is fundamental to authenticate the user sending the request. Our implementation uses an authentication token (typically all platforms have a concept of masked variables or secrets where these tokens can be stored), see Authentication to the ext server of the POST requests.

Action Scripts

Many operations can easily be generalized for all the platforms, for that reason we gathered them in a series of scripts:

  • PREFIX/eclair-VERSION/share/ci/action_log.sh, for more information, see Action Logging;

  • PREFIX/eclair-VERSION/share/ci/action_pull_request.sh, for more information, see Action pull_request;

  • PREFIX/eclair-VERSION/share/ci/action_push.sh, for more information, see Action push;

  • PREFIX/eclair-VERSION/share/ci/action.helpers, for more information, see Action Helpers;

  • PREFIX/eclair-VERSION/share/ci/action.settings, for more information, see Action Settings.

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation).

Action Settings

The script action.settings defines all the variables required by the other action scripts: some of them are information extracted by the runner environment, the others are user settings to configure the actions. The script is included by the other action scripts and hence executed at each action.

Here the main work in terms of generalization has already been done. In fact, many configurations depend on the variable ci that is assumed to be assigned with the platform name by action.helpers. Currently only the GitHub, GitLab and Jenkins are natively supported, but the script can be easily extended to support any CI/CD service.

Changes to the platform-dependent sections should not be required unless the intention is to extend it to new platforms.

The variables include repository information, platform information, and ext server information.

Now a detailed description of these settings follows:

repository

is the repository name; All platforms provide an environment variable containing this information;

event

is a string denoting the event being handled. It could be push or pull_request. All platforms provide an environment variable containing this information;

variantSubDir

is the name of the variant subdirectory. It takes its value from the environment variable VARIANT. It could be the repository name, some characteristic of the build or the analysis (e.g. main_Debug, main_Release, develop_MC3, …);

variantHeadLine

is a string that will be appended to the action headline;

jobDir

is the directory where the generated artifacts related to a specific job are stored. We suggest using the default value;

jobId

is the identifier of the running job. All platforms provide an environment variable containing this information;

jobHeadLine

is the string that will be used as the headline for the analysis page, its value will vary, depending on the action information. We suggest using the predefined values;

subDir

is the name of the directory where the artifacts are stored, its value will depend on event and variantSubDir. We suggest using the predefined values;

badgeLabel

is the label of the analysis badge. We suggest using the default value;

keepOldAnalyses

is the number of analyses stored by the ext server. Older analyses will be deleted. If set to 0 all analyses will be kept.;

artifactsRoot

is the root directory where the artifactsDir in the ext server is created. This variable should be adapted according to the infrastructure setup, see Configuration of the integration;

artifactsDir

is the directory where the generated artifacts related to the project are stored; it must end with .ecdf. We suggest using the default value;

eclairReportUrlPrefix

is the URL of the machine running the ext server. It must include the port. This variable should be adapted according to the infrastructure setup, see Configuration of the integration;

updateLog

is the file where the logs of the POST requests to the ext server are stored. We suggest using the default value;

commentLog

is the file where the logs of the POST requests to platform APIs for the creation of the comments are stored. We suggest using the default value;

indexHtmlUrl

is the file where the HTML page showing the job results is stored. We suggest using the default value;

summaryTxt

is the file where the job results are stored. We suggest using the default value;

Variables that must be defined only if event is pull_request:

pullRequestId

is the identifier of the pull-request. All platforms provide an environment variable containing this information;

pullRequestHeadRef

is the name of the source branch of the pull-request. All platforms provide an environment variable containing this information;

pullRequestHeadRepo

is the name of the source repository of the pull-request. All platforms provide an environment variable containing this information;

pullRequestBaseRef

is the name of the target branch of the pull-request. All platforms provide an environment variable containing this information;

pullRequestUser

is the user that requested the pull-request. All platforms provide an environment variable containing this information.

headCommitId

is the merge point in the source branch of the pull-request. Not all platforms provide an environment variable containing this information. In such cases, the same technique used for GitHub can be used.

baseCommitId

is the merge point in the target branch of the pull-request. Not all platforms provide an environment variable containing this information. In such cases, the same technique used for GitHub can be used.

Variables that must be defined only if event is push:

branch

is the name of the branch. All platforms provide an environment variable containing this information.

GitLab-specific settings:

gitlabApiUrl

is the URL where to send the GitLab API requests for adding comments in the commit and pull-request threads with the analysis results. The value is generated starting from GitLab variables, only the version should be amended (the default is v4).

gitlabBotToken

is the GitLab impersonation token used to authenticate the API requests when the CI_JOB_TOKEN cannot be used. This variable should be adapted according to the infrastructure setup, see Impersonation Token.

Action Helpers

The action.helpers file contains a series of helpers used by the other scripts, many of them are platform-specific.

This file does not require adaptations unless the intention is to extend the existing helpers to new platforms.

Action Logging

Both the push and the pull-request actions log the output of the analysis and report phases into the CI/CD console.

To generalize this task we have prepared the action_log.sh script which is intended to be executed directly from the actions.

Its behavior has been adapted to the specific platform used to ensure the maximum level of integration.

action_log.sh takes four arguments:

SECTION_ID

is an arbitrary identifier for the section

SECTION_NAME

is the name of the section that will be displayed in the console

FILE

is the log file that will be displayed in the console

EXIT_CODE

is an integer number that represents the exit code of the action we are logging. If the provided number is 0, the section will be pre-collapsed (the platform must support that feature)

Action push

This action is intended to perform all the operations needed to analyze the project after a specific push on the repository. The integration implements two different kinds of analysis: one that is automatically triggered at each commit called ECLAIR_normal, one that should be manually triggered called ECLAIR_final. Both the analysis kinds are intended to analyze the project, but ECLAIR_final is intended to generate a wide range of artifacts that may be unwanted for each analysis.

The action is intended to perform the following steps:

  1. set up the environment to build the project;

  2. build and analyze the project;

  3. log the eclair_env diagnostics on the CI/CD console;

  4. log the eclair_report diagnostics on the CI/CD console;

  5. send to the ext server the analysis artifacts and other useful information about the push, see The ext Web Server;

  6. log summary information about the analysis on the CI/CD console;

  7. add a comment with the same summary information on the commit thread in Github and Gitlab and in the pipeline page in Jenkins; This function can be disabled by setting an environment variable called ENABLE_ECLAIR_BOT to no, false, n, 0 or f. If the variable is not defined or defined otherwise, the feature is enabled.

  8. upload the artifacts on the platform.

While these steps except for the last one are platform-independent, the operations required to set up the action are not, please see the relevant section:

Steps 1 and 2 are project-specific; we assume that the user has already prepared specific scripts that take the ANALYSIS_KIND (in our example ECLAIR_final or ECLAIR_normal) variable and completed these tasks. Remember that the runner environment must be prepared with all required softwares, like ECLAIR, the toolchain and other dependencies. It also should be able to retrieve a license for ECLAIR, see Installation of the Runner and Running Actions Within a Docker Container. Under the aforementioned assumptions, the first two steps should look like:

set -eu

# Export the following variable to disable the summary messages
# from the ECLAIR bot.
# export ENABLE_ECLAIR_BOT=n

# Prepare the environment
${SCRIPT_DIR}/prepare.sh "${ANALYSIS_KIND}" ARGS
# Analyze the project
ex=0
${SCRIPT_DIR}/analyze.sh ARGS || ex=$?

The use of the ex variable is required since we are assuming that in the rest of the procedure, other steps are performed independently from its success (set -e interrupts the script at the first error).

Steps 3 and 4 are very similar, we have prepared a script action_log.sh that performs the required logging, see Action Logging.

We assume that analyze.sh redirects in two separate files the logs of the analysis and report phases.

"${SCRIPT_DIR}/action_log.sh" ANALYSIS_LOG \
                            "ECLAIR analysis log" \
                            "${OUTPUT_DIR}/ANALYSIS.log" \
                            "${ex}"
"${SCRIPT_DIR}/action_log.sh" REPORT_LOG \
                        "ECLAIR report log" \
                        "${OUTPUT_DIR}/REPORT.log" \
                        "${ex}"

Now it should be clearer why we have masked the exit code of analyze.sh with the ex variable: we want to log these two files also in case of failure.

Consider now steps 5, 6 and 7 that should not be executed if the analysis fails. We have prepared a script action_push.sh that performs the required actions. Its behavior depends on the settings in action.settings, so make sure it is properly configured. See Action Scripts for general information about this set of scripts.

[ "${ex}" = 0 ] || exit "${ex}"
"${SCRIPT_DIR}/action_push.sh" "${WTOKEN}" "${OUTPUT_DIR}"

action_push.sh takes two arguments:

WTOKEN is the token used to authenticate the POST requests to the ext web server. See The ext Web Server.

OUTPUT_DIR is the directory where the analysis artifacts are located.

Step 8 is obviously platform-specific, see the dedicated section.

Action pull_request

This action is intended to perform all the operations required to analyze the project after a specific pull-request or change in the source branch of an existing one on the repository. The integration implements two different kinds of analysis: one, called ECLAIR_normal, that is automatically triggered and one, called ECLAIR_final, that should be manually triggered. Both the analyses are intended to analyze the project, but ECLAIR_final will also generate a wide range of artifacts that may not always be wanted.

Note

This action is not available in Jenkins.

The action is intended to perform the following steps:

  1. set up the environment to build the project;

  2. build and analyze the project using the branch obtaining merging the source with the target. Please note that in case of conflicts this is not possible;

  3. log the eclair_env diagnostics on the CI/CD console;

  4. log the eclair_report diagnostics on the CI/CD console;

  5. send to the ext server the analysis artifacts and other useful information about the pull-request, see The ext Web Server;

  6. log summary information about the analysis on the CI/CD console;

  7. add a comment with the same summary information on the pull-request thread; This function can be disabled by setting an environment variable called ENABLE_ECLAIR_BOT to no, false, n, 0 or f. If the variable is not defined or defined otherwise, the feature is enabled.

  8. upload the artifacts on the platform.

While these steps except for the last one are platform-independent, how to set up the action is not, please see the dedicated section:

Steps 1 and 2 are project-specific; we assume that the user has already prepared scripts that take at least the ANALYSIS_KIND variable (in our example ECLAIR_final or ECLAIR_normal) and completed these tasks. Remember that the runner environment must be prepared with all required software like ECLAIR, the toolchain and other dependencies. It also should be able to retrieve a license for ECLAIR, see Installation of the Runner and Running Actions Within a Docker Container.

The code to be analyzed should be the code resulting from the merge between the source and the target branches. Usually, all platforms instantiate the job on this temporary branch, please ensure this holds (GitLab does provide merged results pipelines only with the Premium and Ultimate tiers ).

Under the aforementioned assumptions, the first two steps should look like:

set -eu

# Export the following variable to disable the summary messages
# from the ECLAIR bot.
# export ENABLE_ECLAIR_BOT=n

# Prepare the environment
${SCRIPT_DIR}/prepare.sh "${ANALYSIS_KIND}" ARGS
# Analyze the project
ex=0
${SCRIPT_DIR}/analyze.sh ARGS || ex=$?

The use of the ex variable is required since this is assumed by the rest of the procedure; later steps are performed independently of the success of this step (set -e interrupts the script at the first error).

Steps 3 and 4 are very similar, we have prepared a script action_log.sh that performs the required logging, see Action Logging.

We assume that analyze.sh redirects in two separate files the logs of the analysis and report phases.

"${SCRIPT_DIR}/action_log.sh" ANALYSIS_LOG \
                            "ECLAIR analysis log" \
                            "${OUTPUT_DIR}/ANALYSIS.log" \
                            "${ex}"
"${SCRIPT_DIR}/action_log.sh" REPORT_LOG \
                        "ECLAIR report log" \
                        "${OUTPUT_DIR}/REPORT.log" \
                        "${ex}"

Now it should be clearer because we have masked the exit code of analyze.sh with the ex variable: we want to log these two files also in case of failure.

Now we have steps 5, 6 and 7, but this time we do not want to execute them if the analysis fails. We have prepared a script action_pull_request.sh that performs the required actions. Its behavior depends on the settings in action.settings, make sure to configure it properly. See Action Scripts for general information about this set of scripts.

[ "${ex}" = 0 ] || exit "${ex}"
"${SCRIPT_DIR}/action_pull_request.sh" "${WTOKEN}" "${OUTPUT_DIR}"

action_pull_request.sh takes two arguments:

WTOKEN

is the token used to authenticate the POST requests to the ext web server. See The ext Web Server.

OUTPUT_DIR

is the directory where the analysis artifacts are located.

Step 8 is obviously platform-specific, see the dedicated section.

Integrating ECLAIR with GitHub

This section is for anyone who uses GitHub and now needs to know how to integrate ECLAIR with it.

The section assumes that all the platform-independent sections of Integrating ECLAIR with Services for Software Development and CI have been already read, as this section represents an instantiation of them for GitHub.

A demo project showing all the integration possibilities can be found in BUGSENG/eclair_demo.

Installation of the GitHub Runner

For the instruction on how to install a runner in a self-hosted machine see Using self-hosted runners in a workflow.

Using Docker Containers in GitHub

GitHub offers hosted virtual machines to run workflows either directly on virtual machines or in Docker containers, see About GitHub-hosted runners. The installations of ECLAIR, the toolchain and other dependencies become part of the workflow.

If you prefer to run workflows in a self-hosted machine, see About self-hosted runners.

In this case, ECLAIR, the toolchain and other dependencies can be installed during the pipeline or directly in the Docker image. The skeleton provided in Running ECLAIR in Docker Containers can be used with a minimal change: use the myoung34/github-runner Docker image as parent image for your Dockerfile. See Docker Github Actions Runner for further information.

Creation of GitHub actions

In GitHub, the actions are defined through special YAML files.

We have prepared three actions, respectively for the manual, the push and the pull-request events:

PREFIX/eclair-VERSION/share/ci/github/ECLAIR_final.yml

PREFIX/eclair-VERSION/share/ci/github/ECLAIR_normal.yml

PREFIX/eclair-VERSION/share/ci/github/ECLAIR_pull_request.yml

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation).

The above actions create a very deep interaction between GitHub and ECLAIR and do not simply perform an analysis every time they are triggered. The contents of the provided files will be discussed later.

Please remember that they are just examples, or if you prefer, skeletons for your custom actions to be adapted to match your needs.

The files should be placed in

.github/workflows

if the directory does not exist create it.

Now, the actions are ready and at every manual, push and pull_request event, they will be executed.

See GitHub actions documentation for more details.

Actions ECLAIR_final and ECLAIR_normal in GitHub

This section is an instantiation of Action push to GitHub.

ECLAIR_final and ECLAIR_normal are essentially the same action, they differ only in some settings. For this reason, they will be discussed together.

The actions are defined in the following file:

PREFIX/eclair-VERSION/share/ci/github/ECLAIR_final.yml

PREFIX/eclair-VERSION/share/ci/github/ECLAIR_normal.yml

The first lines of both files define an arbitrary name for the action and a list of events that trigger it. We used workflow_dispatch and push: the first one is required to trigger the action from other workflows, the second one triggers the action at every push on the repository.

See Available events for an exhaustive list of them.

See push for an exhaustive description of the push event.

See workflow_dispatch for an exhaustive description of the workflow_dispatch event.

Then, there is the env section. This section is instead used to define environment variables required by the next steps. In our case, we need:

GITHUB_TOKEN contains a secret token to authenticate the requests to the GitHub API required by the integration. The value of the token can be retrieved using the internal variables ${ secrets.GITHUB_TOKEN }

ANALYSIS_KIND contains the kind of analysis. This variable is used to discriminate the operations to perform by analyze.sh for ECLAIR_final and ECLAIR_normal

ENABLE_ECLAIR_BOT enables or disables the ECLAIR messages with summary information on the pipeline page. This feature can be disabled by setting the variable to no, false, n, 0 or f. If the variable is not defined or defined otherwise, the feature is enabled.

See Environment variables for more details.

Now we have reached the most interesting part, where the job is defined. The job name is Analyze, it should run on a specific runner called eclairit (how to set up a runner is described in Installation of the GitHub Runner) and it is composed of seven separate sub-actions:

  • Checkout repository;

  • Build and analyze with ECLAIR;

  • ECLAIR analysis log;

  • ECLAIR report log;

  • Upload ECLAIR artifacts;

  • Upload ECLAIR SARIF;

  • Upload ECLAIR results.

See Using jobs in a workflow for more details.

The first action Checkout repository simply checkout the repository, so the workflow can access it.

It is a standard action defined in the following repository actions/checkout, for our basic usage, we only provide submodules: 'true' in order to checkout also eventual submodules.

Build and analyze with ECLAIR is the most important step where the analysis is actually made.

Assuming analyze.sh takes the ANALYSIS_KIND and creates two log files for the analysis and the report phases, we use two simple cat instructions to log them to the GitHub console. We decided to do that using two sub-actions in order to have two separate collapsable sections in the console.

if: always() is used to ensure that the logging actions will be executed indefinitely from failures during the analysis. For this reason, masking the possible error of analyze.sh as shown in Action push is unnecessary.

The next step is Upload ECLAIR Artifact that simply uploads the produced artifacts so that they will be available from the action page in GitHub under section Artifacts.

It is a standard action defined in the following repository actions/upload-artifact, for our basic usage we only provide name and path that are respectively the name and the path of the artifacts to upload. All the artifacts are created and stored in ECLAIR_out by analyze.sh. Since for debugging reasons is useful having the artifacts also in case of failure, we use if: always().

The next action is Upload ECLAIR SARIF which uploads the SARIF output, that we assume is generated by eclair_report in analyze.sh using -reports_sarif.

The upload is performed by a re-usable workflow defined in BUGSENG/codeql-action, which is a modified version of the standard action github/codeql-action. For our basic usage we only provide sarif_file which is the the path of the SARIF file to upload.

The final step is Publish ECLAIR results, which is performed by action_push.sh, see Action push. This step requires to define the following variable in the enviroment:

WTOKEN is the authentication token. It must be an Encrypted secret. This token will be used to authenticate the user sending the request. The server will search it in the .wtoken file that must be present in the artifactsDir. Create and manipulate the file with -htpasswd

The script is provided with the variables WTOKEN and the directory containing the ECLAIR artifacts.

Action ECLAIR_pull_request in GitHub

This section is an instantiation of Action pull_request to GitHub.

The action is defined in the following file:

PREFIX/eclair-VERSION/share/ci/github/ECLAIR_pull_request.yml

The first lines define an arbitrary name for the action and the events that trigger it. In this case, we set only the pull_request event that has different types, we are interested in opened and synchronize. The first is emitted when a pull-request is opened, the second when a pull request’s head branch is updated. See Available events for an exhaustive list of the events. See pull_request for a detailed description of the pull_request event.

The env section requires the same variable needed in the push action, see Actions ECLAIR_final and ECLAIR_normal in GitHub for a detailed description.

Now we have reached the most interesting part, where the job is defined. The job is defined similarly to the one in the push action, the only difference is in the Publish ECLAIR results action that is specific to the event. We proceed to describe only this different part, for the remaining see Actions ECLAIR_final and ECLAIR_normal in GitHub.

Unlike the other action we have seen, this requires some variables to collect information about the pull-request. These are:

PR_HEAD_REF contains the target branch of the pull-request. The value of the token can be retrieved using the internal variables ${ github.event.pull_request.head.ref }

PR_HEAD_REPO contains the target repository name of the pull-request. The value of the token can be retrieved using the internal variables ${ github.event.pull_request.head.ref }

PR_BASE_REF contains the source branch of the pull-request. The value of the token can be retrieved using the internal variables ${github.event.pull_request.head.repo.full_name}

PR_USER the GitHub user who created the pull-request. The value of the token can be retrieved using the internal variables ${ github.event.pull_request.user.login }

WTOKEN is the authentication token. This token will be used to authenticate the user sending the request. The server will search it in the .wtoken file that must be present in the artifactsDir. Create and manipulate the file with -htpasswd

The run is basically an invocation of action_pull_request.sh which performs the required operations, see Action pull_request.

Authentication in GitHub

GitHub does not save any cookies that can be used to authenticate the file requests, for that reason, one of the general methods in -auth should be used.

Integrating ECLAIR with GitLab

This section is for anyone who uses GitLab and now needs to know how to integrate ECLAIR with it.

The section assumes that all the platform-independent sections of Integrating ECLAIR with Services for Software Development and CI have been already read, as this section represents an instantiation of them for GitLab.

To avoid confusion in this section we will use the specific GitLab terms.

A demo project showing all the integration possibilities can be found in swquality/eclair_demo.

Installation of the GitLab Runner

For the instruction on how to install a runner in a self-hosted machine see Install GitLab Runner.

Using Docker Containers in GitLab

GitLab provides a very easy and convenient approach to dockerization. It is all handled by the runner. The user only needs to register and set it to use Docker executors through a TOML file, see Run your CI/CD jobs in Docker containers.

Please, pay attention that GitLab allows specifying the dockerization through the .gitlab-ci.yml file: avoid relying only on this option as if a user does specify nothing will have access to the CI/CD server.

ECLAIR, the toolchain and other dependencies should be installed during the pipeline or directly in the Docker image, see Running ECLAIR in Docker Containers.

Impersonation Token

In order to add summary messages with the analysis results in the commit and pull-request threads, the integration requires impersonating a platform user by means of a personal access token.

The impersonated user must be authorized to write comments in all threads related to analyzed commits and pull-requests. We suggest creating an ad-hoc account with enough privileges on the target project and calling it ECLAIR.

Create a personal access token for the user by following the instructions in Create a personal access token.

Create a masked variable (see Mask a CI/CD variable), then use it to set gitlabBotToken in action.settings (see Action Settings).

The default name is ECLAIR_BOT_TOKEN, if you use this name you do not need to amend the file.

Creation of GitLab Pipelines

In GitLab, the actions are defined through special YAML files.

We have prepared three pipelines, respectively for the manual, the push and the merge-request events. You can find the file that defines them in:

PREFIX/eclair-VERSION/share/ci/gitlab/.gitlab-ci.yml

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation).

The above actions create a very deep interaction between GitLab and ECLAIR and do not simply perform an analysis every time they are triggered. The contents of the provided file will be discussed later.

Please remember that it is just an example, or if you prefer, a skeleton for your custom actions, adapt it to perfectly match your needs.

The files should be placed in the repository root directory.

Now, the actions are ready and at every manual, push and pull-request, the respective pipelines will be executed.

See CI/CD pipelines for more details.

Defining the pipeline in a separate repository

It is also possible to define the pipelines in a separate repository. This option is very convenient in case we do want to keep the ECLAIR configuration files and script separated from the project itself.

Let’s assume to have two repositories called MY_PROJECT and MY_PROJECT_ECLAIR that are in the same group my_group. MY_PROJECT contains the project to analyze; MY_PROJECT_ECLAIR contains the required scripts and ECL files for the analysis.

Now, the first step is to connect the two GitLab repositories, to do that we need to create a .gitlab-ci.yml file in MY_PROJECT_ECLAIR with the following content:

analyze:
  trigger: my_group/MY_PROJECT

Instead, the old .gitlab-ci.yml contained the pipelines definition should be renamed in gitlab-ci.yml and placed in the root directory.

See trigger for more details.

Actions ECLAIR_final and ECLAIR_normal in GitLab

This section is an instantiation of Action push to GitLab.

ECLAIR_final and ECLAIR_normal are essentially the same pipelines, they differ only in some settings. For this reason, they will be discussed together.

The pipelines are defined in the following file:

PREFIX/eclair-VERSION/share/ci/gitlab/.gitlab-ci.yml

The YAML file contains all the pipelines, please focus your attention to ECLAIR_final and ECLAIR_normal.

The first lines of both pipelines define an arbitrary name and set interruptible: true to allow GitLab to cancel the job when made redundant by a newer run.

See interruptible for an exhaustive description of the interruptible.

ECLAIR_final sets when: manual and allow_failure: false respectively to allow the start of the pipeline only after a manual trigger and to make fail the pipeline in case of failure of the job.

See Create a job that must be run manually for further details.

ECLAIR_normal sets only: -push to automatically run the pipeline at each push on the branch.

Then, there is the variables section. This section is instead used to define environment variables required by the next steps. In our case, we need three variables:

SCRIPT_DIR contains the path where the analysis scripts are located.

OUTPUT_DIR contains the path where the analysis artifacts are created.

ANALYSIS_KIND contains the kind of analysis. This variable is used to discriminate the operation to perform by analyze.sh for ECLAIR_final and ECLAIR_normal

ENABLE_ECLAIR_BOT enables or disables the ECLAIR messages with summary information on the pipeline page. This feature can be disabled by setting the variable to no, false, n, 0 or f. If the variable is not defined or defined otherwise, the feature is enabled.

See GitLab CI/CD variables for more details.

Now we have reached the most interesting part, where the job script is defined.

The job script performs all the required operations already described in Action push, see that section for an in-depth description.

If you want to separate your project from the analysis scripts as explained in Defining the pipeline in a separate repository, just remember to clone the other repository into the current one, a similar script should look like:

variables:
  ECLAIR_REPO: "my_group/${CI_PROJECT_NAME}_ECLAIR"
  ANALYSIS_BRANCH: "master"
  SCRIPT_DIR: "./.gitlab"
  OUTPUT_DIR: "./ECLAIR_out"
script: |
  set -eu
  git clone -b "${RELEASE_BRANCH}" --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}:8444/${PROJECT_PATH}.git "${SCRIPT_DIR}"
  # Prepare for build
  "${SCRIPT_DIR}/prepare.sh"

See script for more details.

The next step is to upload the artifacts the so that they will be available from the job page in GitLab.

We use artifacts to upload them, see Job artifacts for more details.

For our basic usage, we only need:

when: always to keep the artifacts also in case of failure for debugging reasons;

paths: ... that is the list of paths we want to upload;

reports: is a special section that informs GitLab about special report files. In our case ECLAIR is able to produce a report in the GitLab format codeClimate, see Code Quality. We assume the file is generated by eclair_report in analyze.sh using -reports_codeclimate. We provide the file using codequality.

Action ECLAIR_pull_request in GitLab

This section is an instantiation of Action pull_request to GitLab.

The pipeline is defined in the following file:

PREFIX/eclair-VERSION/share/ci/gitlab/.gitlab-ci.yml

The YAML file contains both the merge-request and push actions, please focus your attention to analyze_merge_request.

The first lines of analyze_merge_request define an arbitrary name for the pipeline and a list of events that should trigger it. We used merge_request to trigger the action at every merge request on the repository.

See Merge request pipelines for more details.

Differently from what we said in the general section, this pipeline does not analyze the resulting merged branch, but instead the source one. GitLab offers the so-called merged results pipelines only to premium users. See Merged results pipelines.

The job is defined similarly to the one in the push pipeline, the only difference is in script that is specific for the event. We proceed to describe only this different part, for the remaining see Actions ECLAIR_final and ECLAIR_normal in GitLab.

The job script performs all the required operations already described in Action pull_request, see that section for an in-depth description.

If you want to separate your project from the analysis scripts as explained at the end of Creation of GitLab Pipelines, just remember to clone the other repository into the current one, as already explained in Action ECLAIR_pull_request in GitLab.

Authentication in GitLab

GitLab saves useful cookies that can be exploited to authenticate the file requests, for that reason we suggest using the gitlab method in -auth.

Here is an example:

eclair_report -auth={ARTIFACTS_DIR}/,gitlab,{ECLAIR_REPORT_SERVER}/ \
-server_ext=.. -server_root=/ -server

where ARTIFACTS_DIR is the directory where the analysis artifacts are stored, and ECLAIR_REPORT_SERVER is the URL (including the port) of the machine running the ext server.

Integrating ECLAIR with Jenkins

This section is for anyone who uses Jenkins and now needs to know how to integrate ECLAIR with it without using the plugin.

The section assumes that all the platform-independent sections of Integrating ECLAIR with Services for Software Development and CI have been already read, as this section represents an instantiation of them for Jenkins.

To avoid confusion in this section we will use the specific Jenkins terms.

Installation of the Jenkins Agent

For the instruction on how to install an agent see Using Jenkins agents.

API Token

In order to add summary messages with the analysis results in the pipeline threads, the integration requires impersonating a platform user by means of an API token.

The impersonated user must be authorized to write comments in all threads related to analyzed jobs. We suggest creating an ad-hoc account with enough privileges on the target project and calling it ECLAIR.

Create a API token for the user by following the instructions in Authenticating scripted clients.

Create two credentials of type secret text (see Using credentials), one called ECLAIR_BOT_USERNAME with the username of the user, the other one called ECLAIR_BOT_TOKEN with the API token. Then use these two variables to set jenkinsBotUsername and jenkinsBotToken in action.settings (see Action Settings).

Creation of Jenkins Pipelines

In Jenkins, pipelines can be defined through a step-by-step procedure from its web interface. Depending on the kind of job you want to create the procedure can be slightly different: we assume the reader is familiar with such process.

See Getting Started with Pipelines for further details.

Actions ECLAIR_final and ECLAIR_normal in Jenkins

This section is an instantiation of Action push to Jenkins.

ECLAIR_final and ECLAIR_normal are essentially the same pipelines, they differ only in some settings. For this reason, they will be discussed together.

The procedure depends on the pipeline kind desired, but many steps are the same. This section will go through the common steps related to the integration:

Build Steps

create a build step of kind Execute Shell using the reference script in:

PREFIX/eclair-VERSION/share/ci/jenkins/build_step.sh

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation).

The script defines a series of variables required for the analysis:

SCRIPT_DIR contains the path where the analysis scripts are located.

OUTPUT_DIR contains the path where the analysis artifacts are created.

ANALYSIS_KIND contains the kind of analysis. This variable is used to discriminate the operation to perform by analyze.sh for ECLAIR_final and ECLAIR_normal

ENABLE_ECLAIR_BOT enables or disables the ECLAIR messages with summary information on the pipeline page. This feature can be disabled by setting the variable to no, false, n, 0 or f. If the variable is not defined or defined otherwise, the feature is enabled.

After, the script performs all the required operations already described in Action push, see that section for an in-depth description.

Build Environment

pin the checkbox Use secret text(s) or file(s) and add the secrets required by the integration (WTOKEN, eventually ECLAIR_BOT_USERNAME and ECLAIR_BOT_TOKEN).

Post-build Actions

add an Archive the artifacts action providing the directory where the ECLAIR artifacts are stored.

If you want to separate your project from the analysis scripts as explained in Defining the pipeline in a separate repository, just remember to clone the other repository into the current one, a similar procedure should look like:

export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i '${git_key}'"
[ -d ECLAIR_scripts ] || git clone ssh://git@example.com/repository ECLAIR_scripts
(cd ECLAIR_scripts; git pull --rebase)

We suggest using a secret to store the ssh key to access the repository.

Please remember that it is just an example, or if you prefer, a skeleton for your custom pipelines, adapt it to perfectly match your needs.

Authentication in Jenkins

Jenkins does not save any cookies that can be used to authenticate the file requests; for this reason one of the general methods in -auth should be used.

Warning

Do not use the jenkins authentication method, it is intended to be used with the plugin and not with this kind of integration.

Here is an example:

eclair_report -auth={ARTIFACTS_DIR}/,allow,{ECLAIR_REPORT_SERVER}/ \
-server_ext=.. -server_root=/ -server

where ARTIFACTS_DIR is the directory where the analysis artifacts are stored, and ECLAIR_REPORT_SERVER is the URL (including the port) of the machine running the ext server.

Outputs

The ECLAIR platform can generate outputs for different purposes in many different formats. In this chapter, we introduce the main output formats supported by this version of ECLAIR: Section Report Formats presents them from the end-user point of view, whereas Section Report Tools gives instructions on how to generate them.

If the output formats covered here do not match your needs, please contact BUGSENG to discuss them: due to the unique design of ECLAIR, the results of the analysis can undergo any kind of transformation in order to adapt to any environment and application.

Note

The outputs generated by ECLAIR contain protected intellectual property of BUGSENG srl. Redistribution of any part of such outputs can only happen in accordance with the License Agreement. When some form of redistribution is allowed, the licensed version only supports the generation of textual outputs. The following description of ECLAIR reporting facilities is completely general and does not necessarily reflect the functionality of the ECLAIR instance that was licensed to you.

Report Formats

In this chapter we describe the formats of reports supported by ECLAIR. An ECLAIR report provides information about a circumstance that was detected by some ECLAIR service. Reports can be of different kinds:

All the report kinds provide:

  • the name of the service that generated the report;

  • depending on the report, one or more report areas, which give localized details about the circumstance that is being reported.

A report area (also called main area) provides:

  • the locations of the source code that constitute the area;

  • a message describing the area and its relevance to the overall report;

  • optional report subareas that give additional information about the area itself.

Finally, a report subarea provides:

  • the locations of the source code that constitute the subarea;

  • a message describing the subarea.

Subareas are used to convey information about:

  • the preprocessed version of the code of the main area;

  • the macro expansion chain leading to the main area;

  • the file inclusion chain leading to the main area.

This version of ECLAIR supports two main general formats for the detailed outputs: HTML and pure text. These two formats serve very different purposes and, consequently, they are of a very different nature.

HTML outputs have been designed to be self-contained, complete accounts of all the analyses conducted by means of ECLAIR. So, depending on the analysis and reporting options, these reports may contain, besides the findings of the analysis, full information about the build process together with statistics on the various findings and full project sources both before and after preprocessing. In other words, all the information a developer or quality-assurance person needs for studying and improving the code is available by means of any web browser. HTML outputs are described in Section HTML Outputs.

Textual outputs are ordinary lines of text that can be used for visual inspection, possibly with the help of an editor or an IDE that is able to interpret the location information so as to contextually present the relevant portion(s) of source code. Textual outputs are described in Section Error Reports.

HTML Outputs

The HTML reporting facility provides advanced features for the visualization and navigation of all the information concerning an ECLAIR analysis. By means of any web browser the user has quick access to:

  • information about the build process and the ECLAIR analyses performed;

  • statistics on the various findings;

  • detailed reports about each finding;

  • optionally, full project sources, both before and after preprocessing.

All such information is suitably hyperlinked for easy access and navigation. ECLAIR HTML outputs are compatible with most popular browsers, such as Google Chrome, Mozilla Firefox, Safari, Microsoft Edge and Opera.

The Main Page

The file index.html in the output folder contains the main page of the HTML outputs bundle. At the top is the link

Overall Information

If the service B.EXPLAIN has been enabled, this links to the Configuration page, otherwise the link is void.

The rest of the page consists of three sections.

Project Info:

This section contains a table with information about the project.

Overall Counts:

This section contains four tables, with information on:

  1. the number of enabled services, divided by kind; details about such services (with links to their documentation) can be obtained by clicking on the anchor in the table caption;

  2. the number of analysis frames, divided by kind; details about such frames can be obtained by clicking on the anchor in the table caption;

  3. the number of analysis files, divided by kind; details about such files, divided by directory, can be obtained by clicking on the anchor in the table caption;

  4. the number of reports, divided by report kind; details about reports are available in the next section; clicking on the anchor in the table caption is equivalent to selecting Reports by service and first file in the Detailed Reports section.

Detailed Reports:

This section contains links to more detailed statistical summaries of the reports generated by ECLAIR using the indicated classification:

Reports by service

reports are organized by service;

Reports by first file

reports are organized by first file only;

Reports by service and first file

reports are organized by service and then by first file.

When the user clicks on a link in the left-hand column of a report summary page, the browser enters the selected reports page showing summary information for the selected reports.

Clicking on a link to a service at the left-hand side of the selected reports page, causes the browser to enter a source file page showing the code at the selected location.

We first describe key features common to all the ECLAIR HTML output pages.

Common Features
Color and Column Alignment:

The ECLAIR HTML pages present the report information using color and column alignment to help browsing and selecting the relevant information.

Colored dots, bars and/or rectangles containing the report kind are shown in columns across the relevant vertical region of the page. These columns are ordered and their boxes are colored as follows:

error, violation

red;

caution

orange;

information

yellow;

metric

green.

Navigation Arrows:

In the upper right corner of each page are two navigation arrows < and > for moving back and forward between pages previously displayed in the same browser window.

Home Button:

In the upper right corner of each page, immediately before the navigation arrows, there is a button with a home for moving to the main page in the same browser window.

Scrolling:

On the right of the window is a vertical grey bar showing which section of the whole file is visible. For the report summary pages, the bar can be used to scroll to other parts of the page.

For the selected reports and source file pages, there is a grey circular marker called a scroll handle center-left of this bar; this can be used to move to other parts of the file.

Search:

A search box can be opened using one of ctrl f, ctrl g, or f3.

The search box can be closed using either the esc key or clicking on the X on the extreme right of the search box.

On entering text in the white part of the box, the number of matches found will be displayed in the grey area of the search box and all occurrences visible in the main window will be highlighted (in orange and yellow for the report summary pages and in purple for the selected reports and source file pages).

Also, in a vertical column on the right of the browser window, the distribution of matches in the current file will be shown in the same color (where the vertical size of the browser window represents the entire file).

For the selected reports and source code pages, on the right of the text box are 3 options for improving the search:

Aa:

clicking on this toggles between a case-insensitive or a case-sensitive search;

Ab|:

clicking on this toggles between searching for any matching text or searching only for complete words that match;

.*:

clicking on this toggles between interpreting the entered text as plain text or as a regular expression for the searched character string.

To scroll forward and backward to find other occurrences of the searched text:

scroll to next match:

type f3, ctrl g or enter or click on the > on the right of the search box;

scroll to previous match:

type shift f3 or shift ctrl g or click on the < on the right of the search box;

move the current selection:

to move the current selection to the first visible match or, if not present, to the previous one, click on the circular icon between < and > on the right of the search box.

ECLAIR Button:

In the upper right corner of the pages, between the navigation arrows, there is a box labeled ECLAIR with a set of options. It is displayed on every page, but it can be used only in the Reports Summary, Selected Reports and Source Code pages, in the others the button is inactive. When not all the rules are displayed due to the application of a filter the button will turn red. This box, activated and deactivated by a single click with the mouse left button, is divided into sub-boxes:

Options
Mouse over preview

when set, hovering the mouse over any of the area or subarea boxes will show, either on the preview window or on the preview box, a zoom to the portion of source code in that area.

Preview window

when set, previews will be shown in a new browser window; when unset, previews will be shown in the same browser window.

Current selection

The box allows the creation and storing of named selections. Filter boxes appear once you have selected or created a selection. To create a selection, insert a name for the selection in the text box; then, when a drop down menu appears, click on the Create “{SELECTION_NAME}” entry. The newly created selection will be a copy of the previous one.

Clicking on the link icon next to Current selection, a shareable link, based on the currently shown set of reports, will be automatically created and copied to the clipboard.

By opening the generated link in a browser, it is possible to visualize the same set of reports on a different eclair_report instance. This generated link will depend on the eclair_report server address and port used, and on the location of the database. If the link is used on a different machine, then in order to get the expected behaviour, these should be the same as the machine that generated the link.

It is not required that the target machine contains the same set of selections available in the original one. In fact, all the references to local selections will be expanded and substituted in the link. In this way the link becomes perfectly portable even if the original selection was created using local references.

For these reasons, the link icon feature is particularly useful if used in combination with a remote eclair_report server and a CI/CD system, such as Jenkins (see Integrating ECLAIR with Jenkins).

Area kinds and Subarea kinds

The box allows the selection and deselection of report areas by their area kind or subarea kind. Clicking on an area or subarea kind toggles between selecting and deselecting all areas with that kind. Clicking on the Area kinds or Subarea kinds box name toggles between the simultaneous selection and deselection of all the areas at the same time.

Note that this box is not displayed in the report summary pages.

Hide reports where and Show reports where

The box allows the selection and deselection of reports to be shown. Clicking on the Hide reports where or Show reports where box toggles between the two names. Initially, this box contains Select domain or operator. Clicking here provides a set of selectors:

dir:

allows the selection of reports by the directory containing an area;

file:

allows the selection of reports by the file containing an area;

fingerprint:

allows the selection of reports by their fingerprint;

first_dir:

allows the selection of reports by the directory containing the first main area;

first_file:

allows the selection of reports by the file containing the first main area;

kind:

allows the selection of reports by their report kind;

main_dir:

allows the selection of reports by the directory containing a main area;

main_file:

allows the selection of reports by the file containing a main area;

message:

allows the selection of reports based on the content of the areas;

selection:

allows the selection of reports based on the selections they belong to;

service:

allows the selection of reports by the generating service;

strictness:

allows the selection of reports by the strictness of the generating service;

DOMAIN:

allows the selection of reports by their tags in the specified DOMAIN;

any is true (OR):

opens a list of sub-selectors, any one of which must hold;

any is false (NOT AND):

opens a list of sub-selectors, none of which must hold;

all are true (AND):

opens a list of sub-selectors, everyone of which must hold;

all are false (NOT OR):

opens a list of sub-selectors, not one of which must hold.

If any one of the last 4 options: OR, NOT AND, AND and NOT OR are selected, the expanded text has several framed words or symbols. From left-to-right:

  • clicking on the first toggles between a tick (selector is enabled) and no tick (selector is temporarily disabled);

  • clicking on the second toggles between any and all;

  • clicking on the third toggles between true and false;

  • clicking on the v moves this selector box to be a sub-selector of an OR selector, allowing for alternatives to be added as needed;

  • clicking on the - removes this selector box;

  • clicking on the + adds a new box with Select domain or operator that will provide a new set of selectors.

If any of the other selectors is chosen, a further box appears containing the text Select tags. The expanded text also has a few framed words or symbols. From left-to-right:

  • clicking on the first toggles between a tick (selector is enabled) and no tick (selector is temporarily disabled);

  • clicking on the second toggles between is and is not;

  • clicking on the v makes this selector box to be a sub-selector of an OR selector, allowing for alternatives to be added as needed;

  • clicking on the - removes this selector box.

Clicking on the Select tags box opens a menu with a list of choices relevant to the specified tag domain, any one of which can be selected by clicking on it. Alternatively, by typing directly in the Select tags box:

  • only the matching choices will be shown, or

  • if the typed text begins with ^, the text is interpreted as a regular expression and, in this case, all matching tags will be selected.

To confirm any changes press enter.

If more than one tag is specified, then, next to the tag, there is a checkbox. Clicking on the checkbox, toggles between a tick (tag is enabled) and no tick (tag is temporarily disabled).

Note that by clicking in the white space next to the selected tag or in a different tag box causes the selected tag to be deleted.

Report Summary Pages

These pages show the distribution of the reports utilizing a table and a sunburst chart. The table and the chart show the information according to the selected view and the applied filters. When not all the rules are displayed due to the application of a filter a special hidden column with the counters of the hidden reports appears.

Clicking on row head, counter, or chart sector the browser enters in the selected reports page. Ctrl-clicking on a table entry the selected reports will be opened in a new browser tab, Shift-clicking on a new windows. Shift-clicking on a chart sector the selected reports will be opened in a new browser tab.

Clicking on any column head, it is possible to choose between an ascending or descending sorting.

Ctrl-clicking on a chart sector the entire chart will be recomputed showing only the distribution of the selected sector. The selection only modifies the information visualized by the chart, the view and the table will remain unchanged. To return to the previous configuration click on the button that will appear in the chart center. Hovering with the mouse over a chart sector, a column head or a row head, more information about them will be displayed.

The size of the chart can be increased or decreased by moving the mouse over the chart, pressing Ctrl and using the mouse wheel. The subdivision between the chart and the table areas can be adjusted dragging the gray bar separator. Clicking on the gray bar separator the default subdivision will be restored, if the it is already the default one all page will be completely occupied by the table.

The structure and the information contained in the table and in the chart are completely configurable through the selectors in the top area of the page. User-defined configurations can be saved by giving them a name. A saved configuration is called view.

Namely:

Views

selects the view to display. If the currently displayed view has been modified, it will appear Select.... Now it is possible to save it by clicking on the box, then on Create....

Rows

selects the information to display as row heads. If multiple categories have been selected they will appear hierarchically. This modifies also the configuration of the sunburst chart.

Columns

selects the information to display as column heads. If multiple categories have been selected for each possible combination a column will be created. This modifies also the configuration of the sunburst chart.

Selected Reports Pages

These pages show the list of selected reports using the selected classification.

Each page shows the selected reports with their areas. For each report, the first line shows the report kind and the reported service followed by lines summarising the areas for that report and showing any tags attached to the report.

Each report area line contains its location – the source file name with line and column range – and the message.

On the left of each report kind there is a button.

Clicking with the right mouse button on a report or clicking with the left mouse button on causes a a context-specific menu to appear with actions for the selection/deselection and navigation of the reports.

Namely:

Show help for this service

opens a new browser window containing the ECLAIR manual at the page with documentation for the selected service.

Edit this area

positions the already enabled IDE or editor on the report area for editing. This feature works only if a icon is shown at the beginning of the webpage title. If a icon is shown, your IDE is not properly configured (see Section All ECLAIR Software Runs on the User’s Desktop). It is also possible to use the feature Ctrl-clicking the location link.

Properties

shows all the properties of the report, the rule and the reported code. For each property it is possible, by clicking on the eye icons, enable or disable a filter for that. You can find all the filters enabled by clicking on the ECLAIR (on the top-right corner) button, inside the sub-box Hide/Show reports where. For the properties added with the Tag in browser button, it is also possible remove them by clicking on the X icon. If some text is selected you will find a message property that contains a regular expression with the selected text: all reports whose message matches the expression have this property. In addition to the general method, the message property can be hidden/shown directly after having selected the text by clicking E to exclude it, or I to include it.

Include in selection

shows all the selections not matching the current report. A new selection can be created using the Current selection group of the ECLAIR button (see Common Features). Click on a selection to include in that selection the reports having the same fingerprint of the current report

Exclude from selection

shows all the selections matching the current report. Click on a selection to exclude from that selection the reports having the same fingerprint of the current report

Tagging comment

adds a tagged comment in the IDE or editors above the report area. It is possible to choose between a series of recent comments or create a new one. To create a new one, click on Add Tagging comment action. The first word will be the tag kind, the rest of the string will be the justification (see Section Mark Locally and Justify). By clicking on the button next to a comment you can edit it. This feature requires an already enabled IDE or editor. It works only if icon is shown at the beginning of the webpage title. If a icon is shown, your IDE is not properly configured (see Section All ECLAIR Software Runs on the User’s Desktop).

Run

shows a list of possible script action that you have set. If you click on the action, ECLAIR will call your custom script passing to it a .eca file containing all the information about the report, the violation, and the rule. The script will be execute inside the eclair_report server and it can communicate with it. The name of the action corresponds to the arguments that your script will receive as input. By clicking on the first button on the right, ECLAIR will call your custom script passing to it a .eca file containing the information about all the reports on the current page. By clicking the button, you can edit the script action. To create a new one, click on Add Run action. For more information see Section Custom Get and Run actions in ECLAIR.

Get

shows a list of possible script action that you have set. If you click on the action, ECLAIR will download a .eca file containing all the information about the report, the violation, and the rule. If the user configures the browser to do that, a script will be executed. The execution will be independent of eclair_report server and there is no possibility of communication. The name of the action corresponds to the arguments that your script will receive as input. By clicking on the first button on the right, ECLAIR will call your custom script passing to it a .eca file containing the information about all the reports on the current page. By clicking the button, you can edit the script action. To create a new one, click on Add Get action. For more information see Section Custom Get and Run actions in ECLAIR.

Migrate

allows to import or export JSON files containing the local configuration. Click to Export selections to export a file selections.json containing the selections configured in the browser. Click to Import selections to import selections from a JSON file. Click to Export actions to export a file actions.json containing the selections configured in the browser, the file includes: the tags, the run actions and the get actions added. Click to Import actions to import actions from a JSON file.

On the right of each pair of line and column numbers is a magnifying glass icon. Clicking on this icon a screenshot of the source code area interested by the report will be produced. It is an image that you can save and use as you wish, to copy it right-click on the image and select Copy Image.

Source File Pages

This page shows, for the area selected on the selected reports page, the source file with line numbers as well as additional information about the area(s) located on this page.

The main display has the following features:

  • report boxes showing information about the selected reports and their areas;

  • right marker bars, narrow vertical regions on the right of the browser window which shows, for each report kind, the distribution of reports in the current file where the vertical size of the browser window represents the entire file;

  • left marker bars, narrow vertical regions on the left of the browser window which shows, for each report kind, the location of the reports in the file.

Initially, even if there is more than one area or subarea for the selected report, only the main area is shown: we say that such a report is displayed in condensed form.

Each report area is visualized by two boxes:

  1. a solid-colored box, containing a hamburger icon and the service name;

  2. an outlined box, containing the message.

These boxes which are positioned immediately below the location of the area use coloring depending on the report kind, as described in Common Features).

Hovering the mouse pointer over the service name or area message, highlights the relevant portion of source code using the same coloring as the service name box and adds a pop-up box containing the service’s summary.

How and which reports are shown on this page depends on the current focus:

  • main area focus, a single report is shown in condensed form (this is the initial focus);

  • all areas focus, a single report is shown with all its areas;

  • all reports focus, all reports present in the source file are shown in condensed form;

  • source line focus, all reports are shown for a given report kind and line of code; if there is more than one report for the kind and line, the reports are shown in condensed form.

Clicking the service or message box in the initial state changes the focus from the main area focus to the all areas focus.

Subsequently, clicking the report’s service or message box toggles between all areas focus and all reports focus.

Clicking on a colored dot on the left marker bar or right marker bar switches the display to the source line focus.

Clicking with the mouse button on the icon causes a context-specific menu to appear with actions for the selection/deselection and navigation of the reports. Namely:

Expand this report

expands the current report (if it is not already expanded), hiding all other reports in the file; same as left-clicking on the colored box of a condensed report.

First report

goes to the first report present in the source file; same as typing f.

Previous report

goes to the previous report present in the source file; same as typing p.

Next report

goes to the following report present in the source file; same as typing n.

Last report

goes to the last report present in the source file; same as typing l (the letter ell).

Show All reports

all the reports present in the source file are shown in condensed form (that is it changes to all reports focus); same as typing a.

Mark this report

sets the current report as marked; same as typing m.

Unmark this report

sets the current report as not marked; same as typing u.

Unmark all reports

sets all the reports as not marked.

Hide other services

sets all the reports generated by services other than the service that produced the current report as hidden.

Hide this service

sets all the reports generated by the same service that produced the current report as hidden.

Hide other report kinds

sets all the reports whose kind is different from the kind of the current report as hidden.

Hide this report kind

sets all the reports whose kind is equal to the kind of the current report as hidden.

Edit this area

connects any enabled IDE or editor to the report area for editing (see Section All ECLAIR Software Runs on the User’s Desktop).

Tag this area

uses any enabled IDE or editor to tag the report area shown (see Mark Locally and Justify).

Show help for this service

service specific help is shown.

Custom Get and Run actions in ECLAIR

The HTML interface of ECLAIR (see Section HTML Outputs) can be configured to perform a wide variety of automated actions. This is possible thanks to the use of the highly informative Get and Run requests. These two methods will allow you to define and run custom-designed actions, thereby boosting your workflow.

How They Work

Both Get and Run requests pass the currently selected reports in the browser to a custom script with a series of arguments that can be customized by the action. The custom script will receive the request and perform the task, exploiting the information. The two methods differ in the way they interact with the interface of ECLAIR. Using the Run method you can respond to the request by sending back information that ECLAIR will display within the interface. This is not possible with the Get action; in this case, the request will be processed externally with no further interaction.

The interactions are made possible by means of well-defined JSON files. The structure of these files is explained in Action Requests and in Action Responses.

Mantis Example

To illustrate the use of a custom script, we provide an example of interaction with Mantis. Mantis is a popular web-based bug tracking system and in the example we will see how to create an issue related to a violation directly from the ECLAIR GUI, without adding a single line to the Mantis interface.

You can find the example in:

PREFIX/eclair-VERSION/share/mantis/actions/mantis.ts

where PREFIX and VERSION are the installation prefix of ECLAIR and its version, respectively (see Chapter Installation). Let SCRIPT_PATH be the directory path of this file.

The example is in TypeScript, but any scripting language can be used. It is enough that the script correctly interprets the JSON request provided via /dev/stdin. The example script file is not ready for use and only intended to show how to create automations; it must be adapted to your Mantis settings.

Note that the TypeScript file cannot be interpreted directly and has to be converted to a JavaScript file. An already converted file can be found in SCRIPT_PATH/mantis.js. Since you will probably need to modify the file, we explain here how the delivered JavaScript file was obtained. To do this, Node, which can be downloaded from the Node website, needs to be installed. The steps for the conversion are the following:

cd SCRIPT_PATH
npm install
npm run compile

Now, run the eclair_report server with the -server_area_run_command set to the script path:

eclair_report  "-server_area_run_command=node,SCRIPT_PATH/mantis.js" -db=ECD_FILE -browser -server

Alternatively, if you are using the eclair_gui, the script location can be provided during the View step: click on the + Add argument button next to ECLAIR report server additional args, and add the string:

-server_area_run_command=node,SCRIPT_PATH/mantis.js

In both cases, when writing SCRIPT_PATH use the full path and avoid using any expansion symbol such as ~. Note that there must be no space between node, and SCRIPT_PATH.

If the eclair_report server connects using an IDE or editor directly, then add:

-server_area_run_command=node,SCRIPT_PATH/mantis.js

to the integration plugin settings. This operation differs for each IDE and for each editor; so check how to configure your IDE in Section Integrating ECLAIR with IDEs, Editors, and CI Tools.

Since our example is in NodeJS we have put node as command of -server_area_run_command, and then the script location as first argument.

If your script can be interpreted directly by the shell and script.sh is your custom script file that accepts two input arguments, then the option should be instantiated as follows:

eclair_report "-server_area_run_command='script.sh,arg1,arg2'" -db=ECD_FILE -browser -server

If your script cannot be interpreted directly by the shell (like mantis.js), you have to provide an interpreter (node in our example) followed by a script location. Letting INTERPRETER be the interpreter and EXT the specific extension of the scripting language, the general pattern is:

eclair_report "-server_area_run_command=INTERPRETER,script.EXT" -db=ECD_FILE -browser -server

Note that only one script should be provided but, if you need more features, the custom script can call other scripts. For example, you could use the string content of the action to distinguish the various features.

The provided Mantis script will split the string content of the action into tagged sub-strings and these will be used to set the Mantis fields for the issue. The following tags are supported by the script:

u:{USER} to assign the issue to the Mantis user USER,

c:{CATEGORY} to set the category of the Mantis issue to CATEGORY,

s:{SEVERITY} to set the severity of the Mantis issue to SEVERITY,

p:{PRIORITY} to set the priority of the Mantis issue to PRIORITY,

t:{TAG} to add the TAG tag to the Mantis issue.

Note that, in general, the string content of an action is the only way to provide action-specific information to a script.

It is now time to prepare the action: right-click on a report (or click on ), click on Add Run action then put mantis u:Zoe to assign the issue to the user Zoe. Now, if you click on the action, a request will be sent to the script, which will create an issue on Mantis, assigned to the user Zoe, with the information in the report. It will also attach to the issue a screenshot of the surrounding lines.

An issue page containing all this information will open in your browser; just confirm the submission. Alternatively you can use a Get action in the same way, to download a .eca file and pass it to the mantis script as follows:

node {SCRIPT_PATH}/mantis.js {ECA_PATH}/action-{DOWNLOAD_STAMP}.eca

Action Requests

As explained in selected reports, to create a new action, right-click on a report (or click on ), select Run or Get, and click on Add Run action or Add Get action. Now the interface will ask you to insert a string. This string is not just a mnemonic name for the action, but can be used to provide information to the script.

Note that only one script can be used, so if you want to call many scripts you have to create a general one and then using the string content of the action, to call as needed. Also note that the reports’ information is provided to the script via a JSON file with the extension .eca. It contains all the information about the action, the report(s), the violation(s), and the service(s).

ActionData is the main object containing information about the action and the reports contained in the JSON file.

interface ActionData {
   method: string;
   action: string;
   user: string;
   database: string;
   referer: string;
   project_root: string;
   project_name: string;
   reports: ActionReport[];
}
method

is the run or get method in string format;

action

is the action string, providing information for your script;

user

is the name of the user sending the request in string format;

database

is the absolute path of the database in string format;

referer

is the url of the web page the action came from;

project_root

is the path of the project root in string format;

project_name

is the name of the project in string format;

reports is an array of reports information. The reports listed depend on how the request is created. The GUI allows creating the request with just the selected report or, by clicking on Run action on all visible reports, with all the reports visible in the current page of the GUI.

ActionReport is an object containing information about a single report.

interface ActionReport {
   id: number;
   service: ActionReportService;
   kind: string;
   properties: ActionReportProperty[];
   areas: ActionReportArea[];
   selections: string[];
}

id is a number that denotes the specific report within the database;

service is an object containing information about the ECLAIR service that generates the report;

kind is the report kind in string format;

properties is an array containing the report’s properties

areas is the list of report areas;

selections is the list of the selection names to which the report is associated.

ActionReportProperty is an object containing a property of the report.

interface ActionReportProperty {
   domain: string;
   values: ActionReportValue[];
}

domain is the domain of the property

values is an array containing property values

ActionReportValue is an object containing the value of a property of the report.

interface ActionReportValue {
   value: string;
   doc?: string;
}

value is the value of the property

doc is the documentation optionally attached to the value

ActionReportService is an object containing information about the service that generates the report.

interface ActionReportService {
   id: string;
   summary: string;
   kind: string;
   strictness: string;
}

id is the name of the service (as given in this manual) in string format;

summary is a short text describing the service;

kind is the service kind in string format;

strictness is the strictness of the service in string format.

ActionReportArea is an object containing information about a specific area of a report.

interface ActionReportArea {
   idx: number;
   file: string;
   url: string;
   image?: string;
}

idx is a number identifying the area within the report;

file is the name of the file where the area is located;

url is a URL for the report view at this area. Note that this link only works if the GUI’s server is running;

image is an optional image in base64 format showing a screenshot of the surrounding lines of the code where the area is located.

Action Responses

The Run method is used for interacting with the eclair_report server. There are three different types of response that can be sent back from your script; these are:

  • RunMessageAction

  • RunConsoleAction

  • RunOpenAction

  • RunDownloadAction

Each of these asks for a different kind of action by eclair_report and requires different information. The communication is implemented via JSON files and each kind of request has its own pattern.

RunMessageAction will ask eclair_report to show a Toast notification. A Toast is a unobtrusive window element used to display brief, auto-expiring window of information to the user. The Toast will appear at the top-right corner of the GUI.

interface RunMessageAction {
  action: "info" | "warning" | "error" | "success";
  message: string;
}

action is a string denoting the type of Toast and can be info, warning, error or success;

message is the text to be shown inside the Toast notification.

RunConsoleAction will ask eclair_report server to emit a console message. This action can only be used in a browser and will not work in the GUI. The stream used will depend on the method. If the method is run, then the message is sent to the output stream of the browser. If the method is get then the message is sent to the output stream of the terminal where eclair_report is running.

RunConsoleAction {
  action: "consoleLog" | "consoleErr";
  data: unknown;
}

action is the output stream to be used and can be consoleLog or consoleErr;

data is the message content to be sent to the selected stream.

RunOpenAction will ask eclair_report to open a new webpage.

interface RunOpenAction {
  action: "open";
  url: string;
  target?: string;
}

action is the type of the open action and must be open;

url is the URL of the page to be opened;

target is an optional value denoting where to display the linked URL:

_self will use the current browsing context;

_blank will usually use a new tab, but users can configure browsers to open a new window instead,

_parent will use the parent browsing context of the current one but, if there is no parent, it behaves as if it is _self,

_top will use the top most browsing context (the “highest” context that is an ancestor of the current one) but, if there are no ancestors, it behaves as if it is _self.

RunDownloadAction will ask eclair_report to download a file.

interface RunDownloadAction {
  action: "download";
  fileName: string;
  mimeType: string;
  text?: string;
  data?: string; // Base64
}

action is the type of the download action and must be download;

fileName is the name of the file to download;

mimeType is the Multipurpose Internet Mail Extensions or MIME type of the file to download;

text is the content of the file to download in text format; if this field is set, then data should remain unset;

data is the content of the file to download in base64 format; if this field is set, then text should remain unset.

Error Reports

Errors such as parser errors are reported in textual format by the service B.REPORT.ERR which is always enabled. An error report consists of a few lines of ordinary text, one line for each area and subarea with the following default structure:

POS: error for SKIND SERVICE (SUMMARY) Loc #AREA_NO [TAG: MSG]
POS: Loc #AREA_NO [AKIND: MSG]
...

where:

  • POS specifies the position in the code;

  • SKIND is the kind of the service that generated the report;

  • SERVICE is the id of the service that generated the report;

  • SUMMARY is a summary description of the service SERVICE;

  • AREA_NO is a progressive area number within the report;

  • AKIND is the kind of the area;

  • MSG includes additional information about the area.

Such lines are interspersed with lines of code, which, in turn, can optionally be followed by ASCII markers of the form ^, <> and <~~~> that hint at a position in or portion of the preceding line (see option B.REPORT.ERR snippet).

Example:

The program ex1.c consisting of just the single line of code:

unsinged u;

will produce the following error report (where, as usual, a trailing backslash indicates line continuation):

ex1.c:1.1-1.8: error for parser B.PARSER \
  (The code shall be parsable without errors by the ECLAIR parser. \
   If the code is parsed with errors the AST is incomplete and the \
   results of ECLAIR analyses are likely to be incorrect.) \
   Loc #1 [culprit: unknown type name `unsinged']
unsinged u;
<~~~~~~>
ex1.c:1:1: error: unknown type name 'unsinged'; did you mean \
'unsigned'?
unsinged u;
^~~~~~~~

This says that the offending type name can be found in the source area beginning at line 1, column 1 and ending at line 1, column 8 in ex1.c (where both the line and column numbers are counted starting from 1).

Where the non-compliant code has been obtained by macro expansion, the location will refer to the position of the expansion in the source file, but the report item will also include the text (MACRO) to indicate this. It is also possible to show the source code both before and after the preprocessing stage: for this, use the preprocessed option available to all B.REPORT.* services.

Example:

The following example program ex2.c:

#define int32_t unsinged
int32_t u;

if analyzed using an ECLAIR configuration that includes -config=B.REPORT.ERR,preprocessed=show, will output the following error report:

ex2.c:2.1-2.7: (MACRO) error for parser B.PARSER \
  (The code shall be parsable without errors by the ECLAIR parser. \
   If the code is parsed with errors the AST is incomplete and the \
   results of ECLAIR analyses are likely to be incorrect.) \
   Loc #1 [culprit: unknown type name `unsinged']
int32_t u;
<~~~~~>
<preprocessed ex2.c>:1.1-1.8: for #1 [culprit: preprocessed tokens]
unsinged u;
<~~~~~~>
ex2.c:1.17-1.24: for #1 [culprit: expanded from macro `int32_t']
#define int32_t unsinged
                <~~~~~~>
ex2.c:1:17: error: unknown type name 'unsinged'; did you mean 'unsigned'?
#define int32_t unsinged
            ^~~~~~~~
ex2.c:2:1: note: in expansion of macro 'int32_t'
int32_t u;
^~~~~~~
Browsing Textual Reports

Textual reports can be browsed on-screen like any other compiler-generated diagnostics (warning or error messages). As an alternative, all the textual reports can be redirected to a text file using the option B.REPORT.ERR output, to be available to any post-processing phase required by custom browsing and/or reporting tools.

For emacs users, a simple and useful possibility is to use a command such as the following:

eclair_env -eval_file=FILE \
-project_name=NAME -project_root=TOP_SOURCE_DIR \
-config=B.REPORT.ERR,output=LOG.etr -- make

using the ECLAIR options -eval_file, -project_name, -project_root, and service B.REPORT.ERR. When opening the file LOG.etr on completion of these commands, emacs will automatically enter compilation mode, so that the source location information in the reports will link directly to the corresponding project source code.

Report Tools

When an existing project is checked for compliance with respect to a (new) set of services, if the project or a part of it was not originally coded to comply with those services, it is quite likely that you will have many thousands of reports. Obtaining report counts for each service and/or a statistical sampling of the reports themselves is very helpful in understanding which services (configurations) should not be enabled and which parts of the project should be checked. This is one of the many uses of the eclair_report command.

The eclair_report Command

The eclair_report program is a utility implementing several distinct functionalities.

Creating (or Updating) an ECLAIR Database

To create the ECLAIR database, in the sequel simply called the database, the binary output format should be enabled. A binary output is a file denoted by the extension .ecb. The generation of binary output files is described in Section Reporter B.REPORT.ECB, where the service B.REPORT.ECB is discussed. These files are loaded into the database by using command lines such as

eclair_report -create_db=ECD_FILE -load=ECB_FILE,...
eclair_report -create_db=ECD_FILE ECB_FILE ... -load

All the binary output files listed as arguments in command -load and/or previously listed on the command line will be translated and loaded into a newly created database file called ECD_FILE. Note that the optional argument of -load is a comma-separated list of files: all the options of ECLAIR-related commands taking lists do take comma-separated lists. An obvious consequence is that, if the selection of files to be loaded is defined by means of wildcard patterns, only the second form will work. For example:

eclair_report -create_db=PROJECT.ecd q*.ecb r1?.ecb -load

If the database file already exists, then command lines of the form

eclair_report -db=ECD_FILE -load=ECB_FILE,...
eclair_report -db=ECD_FILE ECB_FILE ... -load

can be used to add the analysis results contained in the given binary output files to the existing database. Note however that this incremental addition will only happen if the database and the binary output files contain the very same information for the project name and project top source directory; if any mismatch is detected, an error is produced and analysis results loading will be interrupted.

The -load command also supports reading the binary output data stream from standard input, using the pseudo-file /dev/stdin as follows:

eclair_report -create_db=ECD_FILE /dev/stdin -load

The -load command sets the tags for all the loaded reports for their associated tag domains.

Opening an ECLAIR Database

If the database of analysis results is contained in a file called ECD_FILE, the command to open it on the default browser is:

eclair_report -db=ECD_FILE -browser -server

If the database is located on a remote machine this operation is still possible. In this case, before we need to start the eclair_report server, then we will be able to open the database from a local browser. The operations required depend on the type of license available in the remote machine.

In the case of a site license the remote server can provide the results without any restriction. eclair_report should be installed and started just in the remote machine.

In the case of a partial coverage license, the remote server cannot provide the results to other machines, so a proxy connection that exploits the local license should be used. Both machines should run eclair_report. This option requires all machines from which we want to access the database to have a license.

The command to start the server is:

eclair_report -server

To open the server access from the local browser to one of the following links:

http://REMOTE_MACHINE:3786/fs/PATH_TO_DB;index.html
https://REMOTE_MACHINE:3787/fs/PATH_TO_DB;index.html

if the remote server does have a site license;

http://localhost:3786/host/REMOTE_MACHINE:3786/fs/PATH_TO_DB;index.html
http://localhost:3786/hosts/REMOTE_MACHINE:3787/fs/PATH_TO_DB;index.html

if the remote server does have a partial coverage license.

In both cases, REMOTE_MACHINE is the address or the DNS alias of the remote machine and PATH_TO_DB is the path of the database.

Producing HTML Outputs

If the database of analysis results is contained in a file called ECD_FILE, the command to produce HTML summaries in folder OUTPUT_DIR is

eclair_report -db=ECD_FILE -summary_html=OUTPUT_DIR

If your license allows that, you can also produce full HTML outputs with the command

eclair_report -db=ECD_FILE -full_html=OUTPUT_DIR

It is important to note that full HTML outputs contain also all the sources that are subjects to reports, suitably annotated. If such sources are not wanted in the HTML outputs (e.g., for confidentiality reasons, the command to be used is

eclair_report -db=ECD_FILE -full_html=OUTPUT_DIR,true

Producing Textual Outputs

If the database of analysis results is contained in a file called ECD_FILE, the command to produce plain text summaries in folder OUTPUT_DIR is

eclair_report -db=ECD_FILE -summary_txt=OUTPUT_DIR

If your license allows that, you can also produce full textual outputs with the command

eclair_report -db=ECD_FILE -full_txt=OUTPUT_DIR

Producing ODT Outputs

ECLAIR supports the production of outputs in ODT format (OpenDocument Text Flat XML format). If the database of analysis results is contained in a file called ECD_FILE, the command to produce ODT summaries in folder OUTPUT_DIR,

eclair_report -db=ECD_FILE -summary_odt=OUTPUT_DIR

If your license allows that, you can also produce full ODT outputs with the command

eclair_report -db=ECD_FILE -full_odt=OUTPUT_DIR

There are summaries in some of the files produced. For technical reasons these cannot be pre-generated, so they will appear incomplete. To properly generate a summary, click ToolsUpdateUpdate All. Doing that procedure all summaries in the document will be updated.

Producing DOC Outputs

ECLAIR supports the production of outputs in OOXML format (Office Open XML, also informally known as DOC or DOCX). If the database of analysis results is contained in a file called ECD_FILE, the command to produce DOC summaries in folder OUTPUT_DIR,

eclair_report -db=ECD_FILE -summary_doc=OUTPUT_DIR

If your license allows that, you can also produce full ODT outputs with the command

eclair_report -db=ECD_FILE -full_doc=OUTPUT_DIR

In some of the files produced there are information that, for technical reasons, cannot be pre-generated. Instead of them placeholders with written Click here and press F9 will appear. These are the summary, the project name, and the timestamp. To properly generate them click on placeholders and press F9. The summary can be updated also by clicking Update Index in the Index group on the References tab.

Additional Ready-Made Output Recipes

The eclair_report output facilities are highly configurable so that any kind of output can be produced. Ready-made recipes are being made available for the most popular output formats: those supported in the version of ECLAIR that was licensed along with this manual are described in this section. Contact BUGSENG to enquire about the availability of more output recipes.

Report Counts According to FCA Norm 7-Z0072

Norm 7-Z0072 of FCA (formerly Fiat Auto) prescribes, among other things, the provision of report counts in a particular Microsoft Excel format. When a database of analysis results has been constructed as previously described, the prescribed file can be automatically generated with a command of the form

eclair_report -db=ECD_FILE -report_counts_7_Z0072=XLS_FILE[,PATTERN]

where ECD_FILE is the database file, PATTERN is a wildcard pattern matching the reported services whose report counts should be included, and XLS_FILE is the name of the desired Excel output file. For example:

eclair_report -db=PROJECT.ecd -report_counts_7_Z0072=file.xls,MC2.*
Metrics Output to Spreadsheet Programs

Program metrics computed by ECLAIR and stored in the database can be exported in a way that makes it easy to post-process them using popular spreadsheet programs. In order to do that, the first step is to produce a particular textual representation of the metrics using a command of the form

eclair_report -db=ECD_FILE -metrics_csv=TXT_FILE

where ECD_FILE is the database file and TXT_FILE is the name of the desired output file, which must have the .txt to make sure it is not misinterpreted by the spreadsheet program. For example:

eclair_report -db=PROJECT.ecd -metrics_csv=metrics.txt

Once that is done, you can work on the metrics data using pivot tables provided with ECLAIR both for Microsoft Excel and for LibreOffice Calc and OpenOffice.org Calc.

With Microsoft Excel open the file

PREFIX\eclair-VERSION\share\metrics\tools\metrics.xlsm

making sure macros are enabled. The Thresholds sheet will be displayed, which contains example thresholds for some metrics: please make sure you set the thresholds according to your needs and coding standards. Then click on the Pivot sheet tab, click on cell A1, containing File on a blue background, and select your TXT_FILE. Then click on cell B2 and select function, unit or program to see the values for metrics defined at that scope.

For LibreOffice Calc or, equivalently, OpenOffice.org Calc, the procedure is almost identical, the only difference being that the file to be opened is

PREFIX/eclair-VERSION/share/metrics/tools/metrics.ods

If warned about the danger of macros, do enable macros. If asked whether to update the links to other files, do accept. Then proceed as for Microsoft Excel.

Note that the pivot tables provided with ECLAIR are just examples: feel free to adapt them to meet your needs.

Available eclair_report Options

We now present some useful commands that allow the user to specify how the reports should be output. A template for the available commands is provided in

PREFIX/eclair-VERSION/share/config/templates/eclair_report.ecl
Option -actions
-actions
-actions[=STATE]

Set server behavior for commands received by remote clients.

STATE:

whether server accept to be administered by remote clients. Accepted values are:

  • true: eclair_report server can be administered by remote clients;

  • false: eclair_report server refuses to be administered by remote clients;

If omitted it is assumed to be true.

Default:

-actions=false

Option -add_data
-add_data
-add_data=APPENDS,...

Add the provided rows to the database specified on the command line (see the -db option).

Example of usage:

eclair_report -db=PROJECT.ecd '-add_data=:t(x,2,y,3,z,4),:t(x,6,y,7,z,8)'

The above example appends to the table t in PROJECT.ecd the rows (x,2,y,3,z,4) and (x,6,y,7,z,8)

APPEND:

append operation to perform. Accepted forms are:

  • :TABLE(ROW): append to TABLE the row ROW

ROW

accepted forms are:

  • CELL: a pair tag-value

  • CELL,ROW: a list of cells

CELL

accepted forms are:

  • TAG,VALUE: element of the row

Option -area
-area
-area=VARIANT

Set the area variant for the current selection.

VARIANT:

area variant id.

Option -auth
-auth
-auth=PREFIX,KIND[,ARG]

Set the authorization list for requests to eclair_report server. First matching entry decides which authentication mechanism should be used.

Only ECLAIR databases and files that are descendants of directories ending with .ecd under the server root can be served if authorized. Files starting with . cannot be served for security reasons.

Without using this option all requests (see -server_root) will be granted.

Example of usage:

Let’s suppose to have two ecdf directories one called allow.ecdf, the other deny.ecdf and that we want to provide access only to files in the first one. The following line can be used:

eclair_report -auth=/test/allow.ecdf,allow -server_root=/test -server

Now, asking 127.0.0.1:3786/fs/test/allow.ecdf/example.txt the server will provide the requested file. Instead, it will return a failure asking a file in /deny.ecdf.

Remember that all paths must be absolute

For examples of authentication methods htpasswd and token see -htpasswd

PREFIX:

the absolute path prefix for matching databases and .ecdf directories.

KIND:

authentication mechanism kind. Accepted values are:

  • allow: allow the access;

  • deny: deny the access;

  • jenkins: ask to Jenkins server using URL specified in ARG;

  • htpasswd: use a file .htpasswd file created with -htpasswd in the folder of the ECLAIR database or one of its ancestors. The browser will ask an username and a password to authentication the request;

  • gitlab: ask to GitLab server using URL specified in ARG;

  • token: use a file .rtokens file created with -htpasswd in the folder of the ECLAIR database or one of its ancestors. Provide rtoken=TOKEN as URL parameter to authenticate the request;

ARG:

Jenkins/GitLab server URL for jenkins/gitlab authorization mechanisms.

Option -auto_shutdown
-auto_shutdown
-auto_shutdown=TIME

Set eclair_report to turn off automatically after a set period of time from when all GUI or browser tabs are closed.

TIME:

the period of time in seconds before the automatic shutdown.

Option -browser
-browser
-browser[=STATE]

Set the browser state when the eclair_report server starts.

STATE:

whether the browser is launched when the server starts. Accepted values are:

  • true: launch the browser when server starts;

  • false: do not launch the browser when server starts;

If omitted it is assumed to be true.

Default:

-browser=false

Option -build_compdb
-build_compdb
-build_compdb=OUTPUT

Output a JSON compilation database of the build as intercepted by ECLAIR.

OUTPUT:

the output file.

Option -build_makefile
-build_makefile
-build_makefile=OUTPUT

Output a Makefile that reproduces the build as intercepted by ECLAIR.

OUTPUT:

the output file.

Option -build_ninja
-build_ninja
-build_ninja=OUTPUT

Output a ninja build file that reproduces the build as intercepted by ECLAIR.

OUTPUT:

the output file.

Option -clear_data
-clear_data
-clear_data=TABLE_GLOB

Remove the table with the TABLE_GLOB tag in the database specified on the command line (see the -db option).

TABLE_GLOB:

tag of the table to remove.

Option -create_db
-create_db
-create_db=ECD_FILE

Create a database file to be used for loading the results.

ECD_FILE:

the database file to be created.

Option -db
-db
-db=ECD_FILE

Specify the database file to be used by following commands.

ECD_FILE:

the database file to be used.

Option -detailed_trial
-detailed_trial
-detailed_trial

Full report details are only exported to files with site/multisite/enterprise license coverage. For trial licenses, it is possible to use this command to consume one of the available tokens to showcase the detailed reports functionality.

Default:

-detailed_trial=false

Option -diff_criteria
-diff_criteria
-diff_criteria=CRITERIA

Specify the criteria to use for detecting common reports between databases.

CRITERIA:

criteria for common reports detection. Accepted values are:

  • fingerprint: consider the service id, the report kind, the report category, the areas kinds, the areas canonical filenames, the areas messages and the tokens in the ranges shown by the areas. This is the default;

  • hash: consider all the information contained in a report. This criteria is not stable since such generated hashes change very easily at any editing of the source file;

Option -diff_full_txt
-diff_full_txt
-diff_full_txt=OLD_DB,NEW_DB

Create for each enabled service two files diff_add.txt and diff_del.txt containing a list of the services respectively with removed and added reports in the provided databases.

Removed reports are the ones that are only in the first database provided.

Added reports are the ones that are only in the second database provided.

The option creates also a directory named diff_output containing, for each enabled service two files SERVICE.del.etr and SERVICE.add.etr containing respectively the removed and added reports in the provided databases.

If you are not interested in these detailed per-service outputs see -diff_summary_txt.

The configuration requires to specify a criteria that will be used to compute the differences using -diff_criteria.

The common reports to both provided databases will be tagged with common in the diff domain.

This information can be easily exploited creating filters in the interactive reports view or when creating any type of artifacts starting from one of the tagged databases.

Example of usage:

eclair_report -diff_full_txt=PROJECT.old.ecd,PROJECT.new.ecd
OLD_DB:

the old database to compare.

NEW_DB:

the new database to compare.

Option -diff_summary_txt
-diff_summary_txt
-diff_summary_txt=OLD_DB,NEW_DB

Create for each enabled service two files diff_add.txt and diff_del.txt containing a list of the services respectively with removed and added reports in the provided databases.

Removed reports are the ones that are only in the first database provided.

Added reports are the ones that are only in the second database provided.

If you are interested in a more detailed output with per-service differences see -diff_full_txt.

The configuration requires to specify a criteria that will be used to compute the differences using -diff_criteria.

The common reports to both provided databases will be tagged with common in the diff domain.

This information can be easily exploited creating filters in the interactive reports view or when creating any type of artifacts starting from one of the tagged databases.

Example of usage:

eclair_report -diff_summary_txt=PROJECT.old.ecd,PROJECT.new.ecd
OLD_DB:

the old database to compare.

NEW_DB:

the new database to compare.

Option -explain_doc
-explain_doc
-explain_doc=OUTPUT

Output the explained ECLAIR configuration in Microsoft Word Flat OPC XML format.

OUTPUT:

the output file.

Option -explain_html
-explain_html
-explain_html=OUTPUT

Output the explained ECLAIR configuration in HTML format.

OUTPUT:

the output file.

Option -explain_odt
-explain_odt
-explain_odt=OUTPUT

Output the explained ECLAIR configuration in OpenDocument Text Flat XML format.

OUTPUT:

the output file.

Option -explain_xml
-explain_xml
-explain_xml=OUTPUT

Output the explained ECLAIR configuration in XML format.

OUTPUT:

the output file.

Option -explain_xslt
-explain_xslt
-explain_xslt=XSLT,OUTPUT

Output the explained ECLAIR configuration as filtered by the specified XSLT file.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file.

Option -files_doc
-files_doc
-files_doc=OUTPUT

Output info about the analyzed files in Microsoft Word Flat OPC XML format.

OUTPUT:

the output file.

Option -files_html
-files_html
-files_html=OUTPUT

Output info about the analyzed files in HTML format.

OUTPUT:

the output file.

Option -files_odt
-files_odt
-files_odt=OUTPUT

Output info about the analyzed files in OpenDocument Text Flat XML format.

OUTPUT:

the output file.

Option -files_txt
-files_txt
-files_txt=OUTPUT

Output info about the analyzed files in pure text format.

OUTPUT:

the output file.

Option -files_xml
-files_xml
-files_xml=OUTPUT

Output info about the analyzed files in XML format.

OUTPUT:

the output file.

Option -files_xslt
-files_xslt
-files_xslt=XSLT,OUTPUT

Output info about the analyzed files as filtered by the specified XSLT file.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file.

Option -first_area
-first_area
-first_area

Show only the first report area, thus omitting all the others, when full reports details are requested using a site/multisite/enterprise license.

Default:

-first_area=false

Option -frames_doc
-frames_doc
-frames_doc=OUTPUT

Output info about the analyzed frames in Microsoft Word Flat OPC XML format.

OUTPUT:

the output file.

Option -frames_html
-frames_html
-frames_html=OUTPUT

Output info about the analyzed frames in HTML format.

OUTPUT:

the output file.

Option -frames_odt
-frames_odt
-frames_odt=OUTPUT

Output info about the analyzed frames in OpenDocument Text Flat XML format.

OUTPUT:

the output file.

Option -frames_txt
-frames_txt
-frames_txt=OUTPUT

Output info about the analyzed frames in pure text format.

OUTPUT:

the output file.

Option -frames_xml
-frames_xml
-frames_xml=OUTPUT

Output info about the analyzed frames in XML format.

OUTPUT:

the output file.

Option -frames_xslt
-frames_xslt
-frames_xslt=XSLT,OUTPUT

Output info about the analyzed frames as filtered by the specified XSLT file.

XSLT:

the XSLT file used to process the XML data.

OUTPUT:

the output file.

Option -full_doc
-full_doc
-full_doc=OUTPUT_DIR

Output the complete project project report in Microsoft Word Flat OPC XML format. The report with front and back covers is written to book.doc, whereas the version without covers is written to index.doc. See -detailed_trial for license-specific information.

OUTPUT_DIR:

the top output directory.

Option -full_html
-full_html
-full_html=OUTPUT_DIR[,NO_SOURCES]

Output the complete project report in HTML format. Main file is index.html. See -detailed_trial for license-specific information.

OUTPUT_DIR:

the top output directory.

NO_SOURCES:

whether to omit sources from project report. Accepted values are:

  • true: omit sources;

  • false: include sources referenced by reports;

If omitted it is assumed to be false.

Option -full_odt
-full_odt
-full_odt=OUTPUT_DIR

Output the complete project report in OpenDocument Text Flat XML format. The report with front and back covers is written to book.odt, whereas the version without covers is written to index.odt. See -detailed_trial for license-specific information.

OUTPUT_DIR:

the top output directory.

Option -full_txt
-full_txt
-full_txt=OUTPUT_DIR

Output the complete project report in pure text format. See -detailed_trial for license-specific information.

OUTPUT_DIR:

the top output directory.

Option -full_xml
-full_xml
-full_xml=OUTPUT_DIR[,NO_SOURCES]

Output the complete project report in XML format. See -detailed_trial for license-specific information.

OUTPUT_DIR:

the top output directory.

NO_SOURCES:

whether to omit sources from project report. Accepted values are:

  • true: omit sources;

  • false: include sources referenced by reports;

If omitted it is assumed to be false.

Option -htpasswd
-htpasswd
-htpasswd=FILE,USER[,PASSWORD]

Add/change entry in .htpasswd like files.

These files can be used with the authentication method htpasswd and token of -auth.

Example of usage with method htpasswd:

Let’s suppose we want to create a .htpasswd file to grant permissions on the directory test/allow.ecdf and its descendants, but not to test/deny.ecdf. The following line can be used:

eclair_report -htpasswd=/test/allow.ecdf/.htpasswd,user,TOKEN
eclair_report -auth=/test/allow.ecdf,htpasswd -server_root=/test -server

Now, asking 127.0.0.1:3786/fs/allow.ecdf/example.txt the browser will ask username and password. Instead, it will return a failure asking a file in /deny.ecdf.

Example of usage with method token:

Let’s suppose we want to create a .rtokens file to grant the same permissions. The following line can be used:

eclair_report -htpasswd=/test/allow.ecdf/.rtokens,user,TOKEN
eclair_report -auth=/test/allow.ecdf,token -server_root=/test -server

Now, asking 127.0.0.1:3786/fs/allow.ecdf/example.txt?rtoken=TOKEN the server will provide the requested file. Instead, it will return a failure asking a file in /deny.ecdf.

Remember that all paths must be absolute

FILE:

password file.

USER:

user name.

PASSWORD:

password (if empty the entry for the user is removed).

Option -json_data
-json_data
-json_data=WHAT,OUTPUT[,OPTS][,FIELDS]

Output the tables provided in WHAT on the specified JSON output file OUTPUT_FILE using the options provided in OPTS and adding the field values FIELDS.

WHAT:

comma-separated list of tables to export.

OUTPUT:

the output file where the selected tables will be exported in JSON format.

OPTS:

comma-separated list of options to use to generate the output file.

FIELDS:

comma-separated list of field values to add to the output file.

Option -load
-load
-load=ECB_FILE,...

Load the .ecb results in the database.

ECB_FILE:

the ECB file to be loaded or /dev/stdin for the standard input. Note that all files in the command line before this command are also loaded.

Option -load_xml
-load_xml
-load_xml=XML_FILE,...

Load analysis results in XML format in the database.

XML_FILE:

the XML file to be loaded or /dev/stdin for the standard input.

Option -lock_timeout
-lock_timeout
-lock_timeout=TIME

Set eclair_report timeout for access to a locked database.

TIME:

the period of time in millseconds before to give up.

Option -metrics_csv
-metrics_csv
-metrics_csv=OUTPUT

Output metrics’ values in textual, TAB-separated form that is suitable for further elaboration with spreadsheet software. The information is extracted from the database specified on the command line (see the -db option). Suitable pivot tables are supplied with ECLAIR for Microsoft Excel, LibreOffice Calc, and OpenOffice.org Calc.

With Microsoft Excel, open the file PREFIX/eclair-VERSION/share/reports/tools/metrics.xlsm making sure macros are enabled.

The Threshold sheet contains example thresholds for the metrics: please make sure to set them according to your requirements. Then open the Pivot sheet tab, click on cell A1, containing File on a blue background, and select the generated OUTPUT file. Then click on cell B2 and select function, unit or program to show the values of the metrics. The metrics, in the Pivot sheet tab, that exceed the thresholds will be shown with a red background.

For LibreOffice Calc or, equivalently, OpenOffice.org Calc, the procedure is almost identical, the only difference is that the file to be open is PREFIX/eclair-VERSION/share/metrics/tools/metrics.ods

Even if warned about the danger of macros, you must still enable macros. If asked whether to update the links to other files, accept. Then proceed as for Microsoft Excel.

Note that the pivot tables provided with ECLAIR are just examples: feel free to adapt them to meet your requirements.

OUTPUT:

the output file.

Option -metrics_tab
-metrics_tab
-metrics_tab=OUTPUT_DIR

Create in the specified OUTPUT_DIR directory a textual, TAB-separated metrics.txt file containing the metrics computed during the analysis. The information is extracted from the database specified on the command line (see the -db option). In the specified OUTPUT_DIR directory two further files are created: metrics.ods and metrics.xlsm, they contain pivot tables that can be used for further elaboration. Finally, a README.txt file is created in the same directory, which contains instructions on the use of the other files.

At least one metrics service (e.g., MET.HIS.GOTO) should be enabled for the analysis used to generate the database, otherwise no directory will be created.

With Microsoft Excel open the file OUTPUT_DIR/metrics.xlsm making sure macros are enabled.

The Threshold sheet contains example thresholds for the metrics: make sure you set them according to your requirements. Then open the Pivot sheet tab, click on cell A1, containing File on a blue background, and select the generated OUTPUT file. Then click on cell B2 and select function, unit or program to show the values of the metrics. The metrics, in the Pivot sheet tab, that exceed the thresholds will be shown with a red background.

For LibreOffice Calc or, equivalently, OpenOffice.org Calc, the procedure is almost identical, the only difference is that the file to be open is OUTPUT_DIR/metrics.ods

Even if warned about the danger of macros, you must still enable macros. If asked whether to update the links to other files, accept. Then proceed as for Microsoft Excel.

Note that the pivot tables provided with ECLAIR are just examples: feel free to adapt them to match your requirements.

OUTPUT_DIR:

the top output directory.

Option -metrics_xslt
-metrics_xslt
-metrics_xslt=XSLT,OUTPUT

Output metrics info as filtered by the specified XSLT file.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file.

Option -overall_doc
-overall_doc
-overall_doc=OUTPUT

Output overall project summary in Microsoft Word Flat OPC XML format.

OUTPUT:

the output file.

Option -overall_html
-overall_html
-overall_html=OUTPUT

Output overall project summary in HTML format.

OUTPUT:

the output file.

Option -overall_odt
-overall_odt
-overall_odt=OUTPUT

Output overall project summary in OpenDocument Text Flat XML format.

OUTPUT:

the output file.

Option -overall_txt
-overall_txt
-overall_txt=OUTPUT

Output overall project summary in pure text format.

OUTPUT:

the output file.

Option -overall_xml
-overall_xml
-overall_xml=OUTPUT

Output overall project summary in XML format.

OUTPUT:

the output file.

Option -overall_xslt
-overall_xslt
-overall_xslt=XSLT,OUTPUT

Output overall project summary as filtered by the specified XSLT file.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file.

Option -protobuf_data
-protobuf_data
-protobuf_data=WHAT,OUTPUT[,OPTS][,FIELDS]

Output the tables provided in WHAT on the specified PROTOBUF output file OUTPUT_FILE using the options provided in OPTS and adding the field values FIELDS.

WHAT:

comma-separated list of tables to export.

OUTPUT:

the output file where the selected tables will be exported in Protocol Buffers (PROTOBUF) format.

OPTS:

comma-separated list of options to use to generate the output file.

FIELDS:

comma-separated list of field values to add to the output file.

Option -quiet
-quiet
-quiet[=STATE]

Set informative messages suppression state.

STATE:

whether the application is quiet. Accepted values are:

  • true: the application does not show informative messages;

  • false: the application show informative messages;

If omitted it is assumed to be true.

Default:

-quiet=false

Option -report_counts_7_Z0072
-report_counts_7_Z0072
-report_counts_7_Z0072=OUTPUT,SERVICES

Output the report counts in XLS format conforming to norm 7-Z0072 of FCA (formerly Fiat Auto).

OUTPUT:

the output file.

SERVICES:

a wildcard pattern matching the services whose report counts should be included.

If omitted it is assumed to be *.

Option -report_counts_doc
-report_counts_doc
-report_counts_doc=DOMAINS,OUTPUT

Output the report counts grouped by tag values for the specified domains in Microsoft Word Flat OPC XML format.

DOMAINS:

the tag domains used to group reports separated by +.

OUTPUT:

the output file.

Option -report_counts_html
-report_counts_html
-report_counts_html=DOMAINS,OUTPUT

Output the report counts grouped by tag values for the specified domains in HTML format.

DOMAINS:

the tag domains used to group reports separated by +.

OUTPUT:

the output file.

Option -report_counts_odt
-report_counts_odt
-report_counts_odt=DOMAINS,OUTPUT

Output the report counts grouped by tag values for the specified domains in OpenDocument Text Flat XML format.

DOMAINS:

the tag domains used to group reports separated by +.

OUTPUT:

the output file.

Option -report_counts_txt
-report_counts_txt
-report_counts_txt=DOMAINS,OUTPUT

Output the report counts grouped by tag values for the specified domains in pure text format.

DOMAINS:

the tag domains used to group reports separated by +.

OUTPUT:

the output file.

Option -report_counts_xml
-report_counts_xml
-report_counts_xml=DOMAINS,OUTPUT

Output the report counts grouped by tag values for the specified domains in XML format.

DOMAINS:

the tag domains used to group reports separated by +.

OUTPUT:

the output file.

Option -report_counts_xslt
-report_counts_xslt
-report_counts_xslt=DOMAINS,XSLT,OUTPUT

Output the report counts grouped by tag values for the specified domains as filtered by the specified XSLT file.

DOMAINS:

the tag domains used to group reports separated by +.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file.

Option -reports_codeclimate
-reports_codeclimate
-reports_codeclimate=OUTPUT

Output untagged cautions and violations in Code Climate JSON format.

OUTPUT:

the output file.

Option -reports_csv
-reports_csv
-reports_csv=OUTPUT

Output report summary data in textual, TAB-separated form that is suitable for further elaboration with spreadsheet software.

The information is extracted from the database specified on the command line (see the -db option).

Suitable pivot tables are supplied with ECLAIR for Microsoft Excel, LibreOffice Calc, and OpenOffice.org Calc.

With Microsoft Excel, open the file PREFIX/eclair-VERSION/share/reports/tools/reports.xlsm making sure macros are enabled. If asked whether to update the links to other files, accept.

In the Pivot sheet tab, you can click on cell A1, containing File on a blue background, and select the generated OUTPUT file. In the same sheet tab you can click on Less detail or More detail to change detail level. The available details are:

  • the reports’ kind;

  • the service name and description;

  • eventual documentation provided to the reports;

  • the directory path of the file containing the reports;

  • the file that contains the reports;

  • the line of the report.

The last fixed column reports provides the the number of reports for the detailed constraints defined by the row.

Row 4 contains the details’ names; by clicking on any of names except the first, it is possible to swap the name with the previous one. Also, swapping columns will reorder the reports.

For LibreOffice Calc or, equivalently, OpenOffice.org Calc, the procedure is almost identical, the only difference being that the file to be opened is PREFIX/eclair-VERSION/share/reports/tools/reports.ods.

Versions of LibreOffice Calc prior to 7.2 are affected by bugs that are triggered by such reports.

Even if warned about the danger of macros, you must still enable macros. If asked whether to update the links to other files, accept. Then proceed as for Microsoft Excel.

Note that the pivot tables provided with ECLAIR are just examples: feel free to adapt them to match your requirements.

OUTPUT:

the output file.

Option -reports_jenkins
-reports_jenkins
-reports_jenkins=OUTPUT

Output untagged cautions and violations in Jenkins XML format.

OUTPUT:

the output file.

Option -reports_sarif
-reports_sarif
-reports_sarif=OUTPUT

Output untagged cautions and violations in SARIF JSON format.

OUTPUT:

the output file.

Option -reports_tab
-reports_tab
-reports_tab=OUTPUT_DIR

Create in the specified OUTPUT_DIR directory a textual, TAB-separated reports.txt file containing report summary data.

The information is extracted from the database specified on the command line (see the -db option).

In the specified OUTPUT_DIR directory two further files are created: these are reports.ods and reports.xlsm, they contain pivot tables that can be used for further elaboration.

Finally, README.txt file is created in the same directory, which contains instructions on the use of the other files.

With Microsoft Excel open the file OUTPUT_DIR/reports.xlsm making sure macros are enabled. If asked whether to update the links to other files, accept.

In the Pivot sheet tab, click on cell A1, containing File on a blue background, and select OUTPUT_DIR/reports.txt. Click on cell B1 to wrap the services descriptions. In the same sheet tab you can click on Less detail or More detail to change the detail level. The available details are:

  • the reports kind;

  • the service name and description;

  • eventual documentation provided to the reports;

  • the directory path of the file containing the reports;

  • the file that contains the reports;

  • the line of the report.

The last fixed column reports provides the the number of reports that have the details specified by the row.

Row 4 contains the details’ names; by clicking on any of names except the first, it is possible to swap the name with the previous one. Also, swapping columns will reorder the reports.

Clicking on the arrow, it is possible to choose between an ascending or descending sorting and create filters on it. E.g., clicking on the arrow in the tag cell is possible to show only the reports related to violations simply by unchecking caution and clicking OK.

For LibreOffice Calc or, equivalently, OpenOffice.org Calc, the procedure is almost identical, the only difference being that the file to be opened is OUTPUT_DIR/reports.ods.

Versions of LibreOffice Calc prior to 7.2 are affected by bugs that are triggered by such reports.

Note that the pivot tables provided with ECLAIR are just examples: feel free to adapt them to match your requirements.

OUTPUT_DIR:

the top output directory.

Option -reports1_doc
-reports1_doc
-reports1_doc=TAG,OUTPUT

Output the reports grouped by tag domains in Microsoft Word Flat OPC XML format. See -detailed_trial for license-specific information.

TAG:

the tag domain used to group reports.

OUTPUT:

the output file where @TAG@ is replaced by tag value.

Option -reports1_html
-reports1_html
-reports1_html=TAG,OUTPUT

Output the reports grouped by tag domains in HTML format. See -detailed_trial for license-specific information.

TAG:

the tag domain used to group reports.

OUTPUT:

the output file where @TAG@ is replaced by tag value.

Option -reports1_odt
-reports1_odt
-reports1_odt=TAG,OUTPUT

Output the reports grouped by tag domains in OpenDocument Text Flat XML format. See -detailed_trial for license-specific information.

TAG:

the tag domain used to group reports.

OUTPUT:

the output file where @TAG@ is replaced by tag value.

Option -reports1_txt
-reports1_txt
-reports1_txt=TAG,OUTPUT

Output the reports grouped by tag domains in pure text format. See -detailed_trial for license-specific information.

TAG:

the tag domain used to group reports.

OUTPUT:

the output file where @TAG@ is replaced by tag value.

Option -reports1_xml
-reports1_xml
-reports1_xml=TAG,OUTPUT

Output the reports grouped by tag domains in XML format. See -detailed_trial for license-specific information.

TAG:

the tag domain used to group reports.

OUTPUT:

the output file where @TAG@ is replaced by tag value.

Option -reports1_xslt
-reports1_xslt
-reports1_xslt=TAG,XSLT,OUTPUT

Output the reports grouped by tag domains as filtered by the specified XSLT file. See -detailed_trial for license-specific information.

TAG:

the tag domain used to group reports.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file where @TAG@ is replaced by tag value.

Option -reports2_doc
-reports2_doc
-reports2_doc=TAG1,TAG2,OUTPUT

Output the reports grouped by primary and secondary tag domains in Microsoft Word Flat OPC XML format. See -detailed_trial for license-specific information.

TAG1:

the primary tag domain to group reports.

TAG2:

the secondary tag domain to group reports.

OUTPUT:

the output file where @TAG@ is replaced by primary tag value.

Option -reports2_html
-reports2_html
-reports2_html=TAG1,TAG2,OUTPUT

Output the reports grouped by primary and secondary tag domains in HTML format. See -detailed_trial for license-specific information.

TAG1:

the primary tag domain to group reports.

TAG2:

the secondary tag domain to group reports.

OUTPUT:

the output file where @TAG@ is replaced by primary tag value.

Option -reports2_odt
-reports2_odt
-reports2_odt=TAG1,TAG2,OUTPUT

Output the reports grouped by primary and secondary tag domains in OpenDocument Text Flat XML format. See -detailed_trial for license-specific information.

TAG1:

the primary tag domain to group reports.

TAG2:

the secondary tag domain to group reports.

OUTPUT:

the output file where @TAG@ is replaced by primary tag value.

Option -reports2_txt
-reports2_txt
-reports2_txt=TAG1,TAG2,OUTPUT

Output the reports grouped by primary and secondary tag domains in pure text format. See -detailed_trial for license-specific information.

TAG1:

the primary tag domain to group reports.

TAG2:

the secondary tag domain to group reports.

OUTPUT:

the output file where @TAG@ is replaced by primary tag value.

Option -reports2_xml
-reports2_xml
-reports2_xml=TAG1,TAG2,OUTPUT

Output the reports grouped by primary and secondary tag domains in XML format. See -detailed_trial for license-specific information.

TAG1:

the primary tag domain to group reports.

TAG2:

the secondary tag domain to group reports.

OUTPUT:

the output file where @TAG@ is replaced by primary tag value.

Option -reports2_xslt
-reports2_xslt
-reports2_xslt=TAG1,TAG2,XSLT,OUTPUT

Output the reports grouped by primary and secondary tag domains as filtered by the specified XSLT file. See -detailed_trial for license-specific information.

TAG1:

the primary tag domain to group reports.

TAG2:

the secondary tag domain to group reports.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file where @TAG@ is replaced by primary tag value.

Option -save_sel
-save_sel
-save_sel

Make current selection persistent saving it in the database.

Option -sel
-sel
-sel=NAME

Set the report filter for the current selection.

NAME:

report filter name.

Option -sel_tag_glob
-sel_tag_glob
-sel_tag_glob=SEL_NAME,DOM,TAGS

Only the reports tagged with one of the provided reports tags will be included in the produced artifacts.

Example of usage:

# Create the diff files and tag the databases:
eclair_report -diff_full_txt=PROJECT.old.ecd,PROJECT.new.ecd

# create an artifact containing only the new violations:
eclair_report -db=PROJECT.new.ecd -sel_tag_glob=new,diff,missing <REPORT_GEN_CMD>

# create an artifact containing only the fixed violations:
eclair_report -db=PROJECT.old.ecd -sel_tag_glob=new,diff,missing <REPORT_GEN_CMD>

Where <REPORT_GEN_CMD> are the options to generate the desired artifact.

If you do not want to create any artifact, but simply navigate the resulting selection use:

eclair_report -db=PROJECT.old.ecd -sel_tag_glob=new,diff,missing -browser -server
SEL_NAME:

the name of the selection. This information will be reported in the produced outputs.

DOM:

the domain of the selection.

TAGS:

a wildcard pattern matching the tags to select. The Unix file globbing syntax can be used.

Option -server
-server
-server[=ACTION]

Perform action ACTION on the server.

ACTION

Accepted values are:

  • start: start the server;

  • stop: stop the server;

  • restart: stop and restart the server;

  • changing: lock the server as database is changing;

  • changed: unlock the server as changes are complete;

If omitted it is assumed to be start.

Option -server_area_run_command
-server_area_run_command
-server_area_run_command=COMMAND,ARG,...

Set the program handling user Run actions.

COMMAND:

the executable called to handle the Run action.

ARG:

argument for the command.

Option -server_ext
-server_ext
-server_ext=PATHNAME[,PROGRAM],ARGS,...

Set the socket (named pipe under Windows) file to be used to forward URIs that begins with /ext/ and optionally the server to launch.

PATHNAME:

the pathname of socket/named pipe file.

PROGRAM:

the server program name.

ARG:

the arguments to be passed to server program.

Option -server_root
-server_root
-server_root=ROOT

Specify the directory to be used as server root for accessing database files.

ROOT:

the root directory to be used.

Default:

-server_root=.

Option -services_doc
-services_doc
-services_doc=OUTPUT

Output info about enabled services in Microsoft Word Flat OPC XML format.

OUTPUT:

the output file.

Option -services_html
-services_html
-services_html=OUTPUT

Output info about enabled services in HTML format.

OUTPUT:

the output file.

Option -services_odt
-services_odt
-services_odt=OUTPUT

Output info about enabled services in OpenDocument Text Flat XML format.

OUTPUT:

the output file.

Option -services_txt
-services_txt
-services_txt=OUTPUT

Output info about enabled services in pure text format.

OUTPUT:

the output file.

Option -services_xml
-services_xml
-services_xml=OUTPUT

Output info about enabled services in XML format.

OUTPUT:

the output file.

Option -services_xslt
-services_xslt
-services_xslt=XSLT,OUTPUT

Output info about enabled services as filtered by the specified XSLT file.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file.

Option -sources_html
-sources_html
-sources_html=OUTPUT

Output sources with related reports in HTML format. See -detailed_trial for license-specific information.

OUTPUT:

the output file where @TAG@ is replaced by tag associated to file name.

Option -sources_xml
-sources_xml
-sources_xml=OUTPUT

Output sources with related reports in XML format. See -detailed_trial for license-specific information.

OUTPUT:

the output file where @TAG@ is replaced by tag associated to file name.

Option -sources_xslt
-sources_xslt
-sources_xslt=XSLT,OUTPUT

Output sources with related reports as filtered by the specified XSLT file. See -detailed_trial for license-specific information.

XSLT:

the XSLT file used to process XML data.

OUTPUT:

the output file where @TAG@ is replaced by tag associated to file name.

Option -ssl
-ssl
-ssl[=STATE]

Set SSL mode.

STATE:

whether eclair_report should use only HTTPS protocol. Accepted values are:

  • true: eclair_report use only HTTPS protocol;

  • false: eclair_report use HTTP protocol if available, otherwise HTTPS;

If omitted it is assumed to be true.

Default:

-ssl=false

Option -ssl_certificate
-ssl_certificate
-ssl_certificate=FILE

Set SSL certificate to be used for HTTPS.

FILE:

certificate file path.

Option -stripped_doc
-stripped_doc
-stripped_doc=OUTPUT_DIR

Output a shorter version of the project report in Microsoft Word Flat OPC XML format. The report with front and back covers is written to book.doc, whereas the version without covers is written to index.doc. See -detailed_trial for license-specific information.

OUTPUT_DIR:

the top output directory.

Option -stripped_odt
-stripped_odt
-stripped_odt=OUTPUT_DIR

Output a shorter version of the project report in OpenDocument Text Flat XML format. The report with front and back covers is written to book.odt, whereas the version without covers is written to index.odt. See -detailed_trial for license-specific information.

OUTPUT_DIR:

the top output directory.

Option -summary_doc
-summary_doc
-summary_doc=OUTPUT_DIR

Output the summarized project report in Microsoft Word Flat OPC XML format. The report with front and back covers is written in book.doc, whereas the version without covers is written in index.doc.

OUTPUT_DIR:

the top output directory.

Option -summary_html
-summary_html
-summary_html=OUTPUT_DIR

Output the summarized project report in HTML format. Main file is index.html.

OUTPUT_DIR:

the top output directory.

Option -summary_odt
-summary_odt
-summary_odt=OUTPUT_DIR

Output the summarized project report in OpenDocument Text Flat XML format. The report with front and back covers is written to book.odt, while the version without covers is written to index.odt.

OUTPUT_DIR:

the top output directory.

Option -summary_txt
-summary_txt
-summary_txt=OUTPUT_DIR

Output the summarized project report in pure text format.

OUTPUT_DIR:

the top output directory.

Option -summary_xml
-summary_xml
-summary_xml=OUTPUT_DIR

Output the summarized project report in XML format.

OUTPUT_DIR:

the top output directory.

Option -verbose
-verbose
-verbose[=STATE]

Set verbosity state.

STATE:

whether the application messages are verbose. Accepted values are:

  • true: messages are verbose;

  • false: messages are not verbose;

If omitted it is assumed to be true.

Default:

-verbose=false

Option -version
-version
-version

Print version number.

Option -xml_data
-xml_data
-xml_data=WHAT,OUTPUT[,OPTS][,FIELDS]

Output the tables provided in WHAT on the specified XML output file OUTPUT_FILE using the options provided in OPTS and adding the field values FIELDS.

WHAT:

comma-separated list of tables to export.

OUTPUT:

the output file where the selected tables will be exported in XML format.

OPTS:

comma-separated list of options to use to generate the output file.

FIELDS:

comma-separated list of field values to add to the output file.

Option -xslt_data
-xslt_data
-xslt_data=WHAT,OUTPUT[,OPTS][,FIELDS]

Output the tables provided in WHAT on the specified XSLT output file OUTPUT_FILE using the options provided in OPTS and adding the field values FIELDS.

WHAT:

comma-separated list of tables to export.

OUTPUT:

the output file where the selected tables will be exported in XSLT format.

OPTS:

comma-separated list of options to use to generate the output file.

FIELDS:

comma-separated list of field values to add to the output file.

Option -yaml_data
-yaml_data
-yaml_data=WHAT,OUTPUT[,OPTS][,FIELDS]

Output the tables provided in WHAT on the specified YAML output file OUTPUT_FILE using the options provided in OPTS and adding the field values FIELDS.

WHAT:

comma-separated list of tables to export.

OUTPUT:

the output file where the selected tables will be exported in YAML format.

OPTS:

comma-separated list of options to use to generate the output file.

FIELDS:

comma-separated list of field values to add to the output file.

Incorporate Third-party reports in an ECLAIR Database

A project using ECLAIR as a static analyzer may want to incorporate as part of its quality metrics the findings of other tools, such as diagnostics from a compiler or test coverage information. In order to give users a uniform report browsing experience, third-party reports may be imported into an ECLAIR database from xml files having a format recognized by eclair_report.

In order to help users generate such files, the eclair_import command is provided.

The eclair_import Command

The eclair_import program is a utility implementing an ECLAIR report generator that parses textual output from a supported third-party tool, such as make or llvm-cov to obtain an XML file that can be fed as input to eclair_report to be incorporated into an analysis database.

Creating XML reports

To create an XML file containing suitably formatted records that can be incorporated into an ECLAIR database, one or more input files containing plain text output from the desired tool should be available.

Consider the following example file diag.c:

int main(int argc, char **argv) {
  enum e { A, B = -1, C};
  enum e e1 = 0x10000;
  e1 + argv[1][0];
  return 0;
}

Compiling this program using the following command line produces several diagnostics:

clang-18 -Weverything diag.c
diag.c:2:12: warning: element 'A' has been implicitly assigned 0 which another element has been assigned [-Wduplicate-enum]
    2 |   enum e { A, B = -1, C};
      |            ^
diag.c:2:23: note: element 'C' also has value 0
    2 |   enum e { A, B = -1, C};
      |                       ^
diag.c:3:15: warning: integer constant not in range of enumerated type 'enum e' [-Wassign-enum]
    3 |   enum e e1 = 0x10000;
      |               ^
diag.c:1:14: warning: unused parameter 'argc' [-Wunused-parameter]
    1 | int main(int argc, char **argv) {
      |              ^
diag.c:4:6: warning: expression result unused [-Wunused-value]
    4 |   e1 + argv[1][0];
      |   ~~ ^ ~~~~~~~~~~
diag.c:4:8: warning: unsafe buffer access [-Wunsafe-buffer-usage]
    4 |   e1 + argv[1][0];
      |        ^~~~
5 warnings generated.

Assume this the file diag.log contains the output above. This can be used to generate an ECLAIR report in XML format in file diag.xml using the following command line

eclair_import -o diag.xml diag.log

Available eclair_import Options

The program eclair_import has several options that can be used to fine-tune the output. A brief description of such options can be obtained by executing eclair_import without any arguments or eclair_import --help. In the following sections these options are explained in greater detail.

Option –projectName (–name)
--projectName <NAME>, --name <NAME>

A name for the project to which the reports belong to can optionally be specified via the --projectName or --name options. It is analogous to the eclair global -project_name.

Option –projectRoot (–root)
--projectRoot <DIR>, --root <DIR>

The root directory relative to which all files to be analyzed are assumed to be present. It is analogous to the eclair global -project_root.

Option –frame
--frame <FRAME_ID>

The option --frame allows setting the frame id for the reports generated from the input file(s). Every ECLAIR report is generated from an analysis frame and the frame id is a property of the report. Setting this value may be necessary in order to avoid importing into a database reports with overlapping frame ids. The default value is 1000.

Option –command (-c)
--command <CMD>, -c <CMD>

This option sets the command that produced the reports extracted from the input file(s). This value is used and displayed by eclair_report. The default value is "".

Option –delivery (-d)
--delivery <VARIANT>, -d <VARIANT>

This option sets the analysis variant that produced the reports. It is analogous to the eclair global -variant. The default is "gcc".

Option –commit
--commit <SHA>

This option sets the commit that the input file(s) refer to. The default is "".

Option –service (-s)
--service <SERVICE_ID>, -s <SERVICE_ID>

This option sets the default id for the ECLAIR service of reports generated from the input. This service id is used if no value can be extracted from the input, such as diagnostic names from a compiler (e.g., -Wunused-parameter). The default is diagnostic.

Option –summary
--summary <SUMMARY>

This option sets the default service summary for the reports generated from the input. This service summary is used if no value can be extracted from the input, such as the diagnostic names from a compiler (e.g., -Wunused-parameter). The default is diagnostic.

Option –service_kind
--service_kind <SERVICE_KIND>

This option sets the default service kind for the services to which the reports generated from input files refer to. The default is diagnostic.

Option –report_kind
--report_kind <REPORT_KIND>

This option sets the default report kind for the reports generated from the input. The default is diagnostic.

Option –presumed (-p)
--presumed, -p

Adds an area with area kind PRESUMED to the report referring to the location in the input file from which the generated report was extracted from.

Option –artifactsdir (-a)
--artifactsdir <DIR>, -a <DIR>

The directory where the files mentioned in the input files are stored. Note that this might differ from the project root. If set, the specified path will be used to construct the path to search the resource indicated in the input file /path/to/file.c as follows:

artifactsdir/file.c

It is unset by default, in which case the paths indicated in the input are used to find the referenced files.

Option –parser
--parser <PARSER_NAME>

The parser to be used to process the input files. Depending on the tool that generated the input, a different parser should be used:

  • make, cmake, compiler diagnostics output: GCC

  • llvm-cov MC/DC output: LLVM_COV

The default value is GCC

Option –output (-o)
--output <FILE>, -o <FILE>

This option allows setting the XML output file name containing ECLAIR reports. The default value is frames.xml.

Option –version
--version

Shows the version number for eclair_import. This matches the current version of ECLAIR.

Importing XML reports into an ECLAIR Database

Assuming that output.xml is a file containing ECLAIR reports in XML format obtained by an invocation of eclair_import, an ECLAIR database can be created by a command line such as

eclair_report -create_db=ECD_FILE -load_xml=output.xml

All the reports contained in output.xml will be included in the newly created database file ECD_FILE. Optionally, reports obtained from an analysis with ECLAIR can be included in the same database, if there aren’t overlapping frame ids between the two sets of reports. Refer to Creating (or Updating) an ECLAIR Database for further information on creating or updating ECLAIR databases.

Configuration

The obvious counterpart to the extreme configurability of ECLAIR is that its configuration might be quite complex. However, many users are simply given an ECLAIR configuration file in ECL format and they only need to know how to give it to ECLAIR: such users can skip this chapter altogether. Only a minority of users will need to know more about ECLAIR options and how to express them in ECL. These are the users who are involved in the writing or modification of scripts and advanced configurations: they will find all they need in this chapter and in Sections Global Options and Generic Service Options.

Common Configuration Concepts

This section describes some common concepts used when setting the ECLAIR configuration options for analyzing a project.

String Interpolation

String interpolation allows the composition of strings from string literals and ECL expressions. The juxtaposition of a string literal (that is, a possibly empty sequence of characters enclosed in double quotes) followed by a sequence of expressions and string literals denotes string interpolation. Note that every string interpolation must be introduced by a string literal, possibly the empty string "". Note also that the sequence cannot contain two adjacent expressions: for example, two adjacent variable names would be interpreted as the name of a single variable; again, the empty string can be used to separate expressions in the sequence.

An expression can be any ECL expression: this allows for full generality. However, for most users it is sufficient to know that expressions include the following predefined variables:

An example of string interpolation is

""install_dir"/share/dict/en_US"

which is expanded to

PREFIX/eclair-VERSION/share/dict/en_US

Note the empty string occurring as the first element of the juxtaposition in order to introduce string interpolation.

An expression can also be a function invocation, such as:

  • join_paths(PATH,...) takes one or more path components (i.e., file or directory names) and joins them by interposing a system-dependent delimiting character (the slash / or the backslash \);

  • getenv(NAME) gives the value of environment variable named NAME;

  • windows_wildcard_regex(WINDOWS_PATH) takes a Windows path, possibly with wildcards, and turns it into a corresponding regular expression performing all the necessary quoting.

For instance, the example above can be rewritten in a more portable way as follows:

""join_paths(install_dir,"share","dict","en_US")

or, assuming a suitable definition for the DICTIONARY environment variable,

""join_paths(install_dir,"share","dict",getenv("DICTIONARY"))

Booleans

Whenever eclair_env requires a Boolean parameter, the following can be specified:

  • false

  • true

Matchers

Several commonly-used (often global) configuration options use matchers. A matcher defines a constraint on the elements specified by the configuration option; if the constraint on the element holds, the matcher is said to match the element.

A matcher is an expression formed from atomic selectors with the usual Boolean operators !, ||, && together with the addition operators + and -. The atomic selectors include

  • parenthesized expressions,

  • named matchers: an element matches the identifier if it matches the associated matcher expression;

  • any(): any element matches,

  • none(): no element matches

  • built-in selectors that depend on the specific matcher; the syntax and constraints checked by such a selector is defined by the configuration option for the matcher.

An example of a matcher is the global configure option entity_selector defined in Global Options.

Short Circuit Taggers

Several commonly-used configuration options are short circuit taggers with values in the form of an ordered sequence of short-circuit clauses.

In its simplest form, each short-circuit clause is a pair consisting of a tag and some conditions; the tag takes one of a set of values defined by the configure option and the conditions takes a value or values that define a condition COND on the data being examined. Note that a set or sequence of conditions is interpreted as a conjunction of the conditions they specify. If the data being examined by ECLAIR satisfies COND, then we say that the short-circuit clause matches the data.

The relevant data being examined by ECLAIR is checked against the conditions of each short-circuit clause in the tagger (in the sequential order of the clauses) until a match is found. The tag in the first short-circuit clause that matches the data is then assigned to the data. When there is no matching short-circuit condition, then, the data is given a default tag (defined by the configure option).

More generally, a short circuit clause may include additional arguments that are not part of the conditions but may affect the report output. A common use for such an argument is for the user to specify a message to be included in the report or a justification for hiding a report.

An example of a short circuit tagger is the global configure option source_files defined in Global Options. The values for tag are hide and show, with the default tag being show.

Output Sinks

Whenever eclair_env requires the specification of an output sink, the specification can be prefixed by:

  • >>, in which case the rest of the atom is interpreted as a filename to be opened in append mode;

  • >, in which case the rest of the atom is interpreted as a filename to be opened in truncate mode (that is, if the file already exists, its contents is overwritten);

  • |, in which case the rest of the atom is interpreted as a command to which the output should be piped.

If such a prefix is not present, then the entire atom is interpreted as a filename to be opened in a use-dependent mode. The mode is append (i.e., the file is created if it does not exists and writing takes place at the end of the file) for the output of diagnostics and of report data files that are meant to be constructed incrementally. The mode is truncate (i.e., the file is created if it does not exists, it is truncated to zero length if it does exist, and writing takes place at the beginning of the file) in all other cases. The defaults have been chosen so that the vast majority of users will never need to use the >> and > specifiers.

Regular Expressions

A regular expression (shortened as regex or regexp) is a sequence of characters that specifies a search pattern in text.

See Syntax quick-reference summary for the precise syntax details.

Note that when a regular expression is written inside a string literal there are two levels of quoting: one introduced by the string literal and the other one by the regular expression.

For example, consider the configuration:

-call_properties+={"^foo\\(.*$",{noreturn}}

The string literal ^foo\\(.*$ is expanded first, replacing the \\ by \, so that the expansion of the regular expression will interpret the \( as a verbatim ( and not as a group begin.

Documenting Configurations

We first describe some special options for documenting the configuration itself.

Option -doc

-doc

-doc=DOC...

where DOC is a comment that explains the next line of the configuration.

Option -doc_begin

-doc_begin

-doc_begin=DOC...

where DOC is a comment that explains the block of configuration lines that follows.

Option -doc_end

-doc_end

terminates a documented block of configuration lines.

Global Options

We present some useful global configuration options that are service-independent but project specific. For service-dependent options that can be used with any service see Generic Service Options.

A template for the configuration of global options is provided in

PREFIX/eclair-VERSION/share/config/templates/globals.ecl

Configuration

Option -load_config
-load_config
-load_config=INPUT

Load the specified compiled configuration file.

The input file must be obtained using the -save_config global option.

The option loads all the configurations contained in the input file similarly to what -eval_file does for an ECL file.

The only difference is that the latter needs to recompile the ECL file at each COMMAND frame causing a significant overhead. It is suggested to use this option in projects with many COMMAND frames, and/or that use large ECL files.

Example of usage:

eclair -record_config -eval_file=configuration.ecl -save_config=configuration.cecl
eclair_env -load_config=configuration.cecl -- ...
INPUT:

a compiled configuration file.


Option -record_config
-record_config
-record_config

Mark the beginning of configuration commands that should be saved by -save_config.

Only the configuration commands will be placed in the output file, other commands will be ignored.

Example of usage:

eclair -record_config -eval_file=configuration.ecl -save_config=configuration.cecl
eclair_env -load_config=configuration.cecl -- ...

Option -save_config
-save_config
-save_config=OUTPUT

Save the compiled output of configuration commands received since the last -record_configin the specified file.

The obtained output file can be used later with the -load_config global option.

Only the configuration commands will be placed in the output file, other commands will be ignored.

Example of usage:

eclair -record_config -eval_file=configuration.ecl -save_config=configuration.cecl
eclair_env -load_config=configuration.cecl -- ...
OUTPUT:

the output file.


Option -variant
-variant
-variant=FRAME_MATCHER

Configuration variants introducer.

FRAME_MATCHER:

a -frame_selector identifier or a matcher expression used to select the frames where to use following configurations.

Default:

-variant=""

Actions

Option -config_file
-config_file
-config_file=FILE_NAME

Loads the given configuration file.

Unlike -eval_file, -config_file compiles the configuration files only once during the CLEAN frame and then the compiled version is reused in the remaining frames.

-eval_file re-compiles the configuration files at each frame.

This command can be used only once, hence the specified file should use -eval_file to include all the needed configuration files.

FILE_NAME:

configuration file to be loaded, usually including the full absolute path (omitting the path or providing a relative path is not recommended, as the file will then be looked for in a directory relative to the current directory of the build process).


Option -eval_file
-eval_file
-eval_file=FILE_NAME,...

Loads the given configuration files in left-to-right order.

The configuration’s content is an ordered list of configurations files to be loaded.

FILE_NAME:

configuration file to be loaded, usually including the full absolute path (omitting the path or providing a relative path is not recommended, as the file will then be looked for in a directory relative to the current directory of the build process).


Option -eval_string
-eval_string
-eval_string=ACTION,...

Commands to be executed.

The configuration’s content is an ordered list of commands to be executed.

ACTION:

the command to be executed.


Option -post
-post
-post=ACTION,...

Commands to be executed after toolchain detection.

The configuration’s content is an ordered list of commands to be executed after toolchain detection.

ACTION:

the command to be executed.


Project information

Option -project_name
-project_name
-project_name=NAME

Project name.

NAME:

the name of the project.

Default:

-project_name=unnamed

Option -project_root
-project_root
-project_root=DIRECTORY

Project root directory.

DIRECTORY:

the top source directory of the project.

Default:

-project_root=/dev/null

Option -source_files
-source_files
-source_files={TAG, FILE_MATCHER},...

Specifies the source files to be excluded from the analysis.

The configuration’s content is a short-circuit sequence specifying the sources files for which the top level declarations and tokens should not be analyzed.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

FILE_MATCHER:

a -file_tag identifier or a matcher expression used to select the files.


Analysis

Option -frame_override
-frame_override
-frame_override=OVERRIDE

If enabled, data collected from analysis for the same target, the same command line and the same current working directory will replace previous data.

OVERRIDE:

specify if new analysis frame should override previous similar analysis frame. Accepted values are:

  • false: old analysis data is not overridden;

  • true: old analysis data is discarded;

Default:

-frame_override=false

Option -frames
-frames
-frames={TAG, FRAME_MATCHER},...

Specifies the analysis frames to be excluded from the analysis.

The configuration’s content is a short-circuit sequence specifying the frames that should not be analyzed.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

FRAME_MATCHER:

a -frame_selector identifier or a matcher expression used to select the frames.


Launching the compiler

Option -compile
-compile
-compile=WHAT

Specify which source should be compiled.

WHAT:

the source format. Accepted values are:

  • original: compile the original source;

  • nothing: don’t call the target compiler;

Default:

-compile=original

Remapping

Option -remap_file
-remap_file
-remap_file={FROM, TO},...

This will map a file name into another file name in the ECLAIR parser.

The configuration’s content is a set of file redirections.

FROM:

the file name to be remapped.

TO:

the target file name.


Option -remap_include
-remap_include
-remap_include={FROM, TO},...

This will map an include name into another include name in the ECLAIR parser.

The configuration’s content is a set of include redirections.

FROM:

the include name to be remapped.

TO:

the target include name.


Option -remap_rtag
-remap_rtag
-remap_rtag={FROM, TO},...

This will map a report tag into other report tags. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden.

The configuration’s content is a set of rtag mappings.

FROM:

the rtag to be remapped.

TO:

a possibly empty sequence of rtags separated by +.

Default:

-remap_rtag={}

Idioms

Option -loop_idioms
-loop_idioms
-loop_idioms={STMT, LOOP_MATCHER},...

Specify the loop idioms.

The configuration’s content is a set of loop kinds with condition matcher.

STMT:

for, do or while statement. Accepted values are:

  • for_stmt: for statement;

  • do_stmt: do statement;

  • while_stmt: while statement;

LOOP_MATCHER:

a matcher expression for the loop conditions. Accepted forms are:

  • [+]AND_MATCHER: the loop matches AND_MATCHER

  • -AND_MATCHER: the loop does not match AND_MATCHER

  • [+]AND_MATCHER||LOOP_MATCHER: either the loop matches AND_MATCHER or it matches LOOP_MATCHER

  • -AND_MATCHER||LOOP_MATCHER: the loop does not match AND_MATCHER but does match LOOP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (LOOP_MATCHER): the loop matches LOOP_MATCHER

  • !BASIC_MATCHER: the loop does not match BASIC_MATCHER

  • any(): any loop matches

  • none(): no loop matches

  • macro(): the loop is an expanded macro

  • empty_head(): the loop is a for statement with an empty head

  • literal(NUM): the loop condition must be the integer NUM, which is 0 or 1

  • constant(BOOL): the loop condition must be the Boolean BOOL, which is true or false

  • eval(NUM): the loop condition expression must evaluate to NUM, which is 0 or 1

  • type(boolean): the loop condition expression must have a Boolean type not considering implicit conversions

Default:

-loop_idioms={do_stmt, "macro()&&constant(false)"}

Diagnostics output

ECLAIR diagnostics output can be set in two different ways: the preferred one is via the ECLAIR_DIAGNOSTICS_OUTPUT environment variable; this has the advantage that the setting is active even before the command line is parsed and before any ECL file has been read. The following global setting provides an alternative that can be used when, at some stage, the diagnostics output is to be diverted to a different output sink.

Option -diagnostics_output
-diagnostics_output
-diagnostics_output=DIAG_OUTPUT

Specify the output file for the diagnostics.

DIAG_OUTPUT:

the file name for the diagnostics output.

Default:

-diagnostics_output=/dev/stderr

Extra output

Option -print
-print
-print=PRINT

Specify extra text to be printed.

PRINT:

text to be printed.


Option -verbose
-verbose
-verbose=LEVEL

Verbosity level.

LEVEL:

the level of verbosity. Accepted values are:

  • false: less verbose;

  • true: more verbose;

Default:

-verbose=false

Option -version
-version
-version

Print version number.


Report control

Option -entity_declarations
-entity_declarations
-entity_declarations={TAG, DECL_MATCHER},...

Select declarations to be used for entity presentation.

The configuration’s content is a short-circuit sequence specifying which declaration to choose when presenting an entity.

TAG:

a tag with values hate and show. Accepted values are:

  • hate: avoid when possible if it matches the associated conditions;

  • show: show if it matches the associated conditions;

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option -fmt
-fmt
-fmt={FMT, TPL_FMT, CONTENT},...

Specify the formats for the messages.

The configuration’s content is a collection of named message formats.

FMT:

format identifier.

TPL_FMT:

template identifier.

CONTENT:

format content string. Accepted forms are:

  • PARTPARTS: non empty parts

  • : empty parts

PART

accepted forms are:

  • %{EXPR}: result of EXPR

  • TEXT: text TEXT

EXPR

accepted forms are:

  • 'TEXT': text TEXT

  • n(PARAM): value of parameter PARAM

  • q(PARAM): quoted value of parameter PARAM

  • seq(EXPR,SEP): value of items in list EXPR separated by SEP

  • cond(EXPR_COND,EXPR_DEFAULT,CASES): value of EXPR_COND is tested against CASES, if nothing matches EXPR_DEFAULT is used

  • FMT(OPT_ARGS): fmt FMT is called

  • FMT(EXPROPT_COMMA_SEPOPT_COMMA_ARGS): fmt FMT is called on EXPR

  • ifmt(EXPR_FMT,IDOPT_COMMA_ARGS): fmt specified by EXPR_FMT (whose template is ID) is called

  • ifmte(EXPR_FMT,EXPR_VALUEOPT_COMMA_ARGS): fmt specified by EXPR_FMT is called on EXPR_VALUE

  • ifmts(EXPR_FMT,EXPR_SEQ,EXPR_SEPOPT_COMMA_ARGS): fmt specified by EXPR_FMT is called on sequence EXPR_SEQ using separator EXPR_SEP

OPT_ARGS

accepted forms are:

  • ID:EXPROPT_COMMA_ARGS: optional comma separated EXPR sequence

  • : no more expressions

OPT_COMMA_ARGS

accepted forms are:

  • ,OPT_ARGS: optional comma separated OPT_ARGS sequence

  • : no more args

OPT_COMMA_SEP

accepted forms are:

  • ,EXPR: comma followed by EXPR

  • : no more expressions


Option -ignored_comments
-ignored_comments
-ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-ignored_comments=__eclair_rtag_comments

Option -program_presentation_style
-program_presentation_style
-program_presentation_style=STYLE

Specify the output style for report program reference.

STYLE:

sets the output style; the default is to include the full linker command. Accepted values are:

  • include_full_command: file name with full linker command;

  • file_name_only: main file name without the full linker command;

Default:

-program_presentation_style=file_name_only

Option -reports
-reports
-reports={TAGS, REPORT_MATCHER},...

Specifies the report tags for reports.

The configuration’s content is a list of clauses specifying the reports and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option -tool_name_style
-tool_name_style
-tool_name_style=STYLE

Specify the output style for the tool used.

STYLE:

sets the tool name style; the default is the full name. Accepted values are:

  • full_name: full name of tool including the path;

  • base_name: name of tool excluding the path;

Default:

-tool_name_style=full_name

Option -unit_presentation_style
-unit_presentation_style
-unit_presentation_style=STYLE

Specify the output style for report unit reference.

STYLE:

sets the output style; the default is to include the full compilation command. Accepted values are:

  • include_full_command: file name with full compilation command;

  • file_name_only: main file name without the full compilation command;

Default:

-unit_presentation_style=file_name_only

Services

Option -disable
-disable
-disable=SERVICE,...

Services to disable.

The configuration’s content is a set of services to disable.

SERVICE:

a -service_selector identifier or a matcher expression used to select services.

Default:

-disable={}

Option -enable
-enable
-enable=SERVICE,...

Services to enable.

The configuration’s content is a set of services to enable.

SERVICE:

a -service_selector identifier or a matcher expression used to select services.

Default:

-enable={}

Metrics

Option -metrics
-metrics
-metrics={METRIC, SPECIFIER, SUMMARY},...

Specify custom metrics based on those already present.

The configuration’s content is a collection of named metric definitions.

METRIC:

the identifier for the custom metric.

SPECIFIER:

an expression that specifies the custom metric. Accepted forms are:

  • AGGR_ID(ID_BASE,AGGR_CTX): aggregated metric using ID_BASE as the basis

  • EXPR: expression of other metrics

AGGR_ID

accepted forms are:

  • max: the maximum of all base metric values for the specified context

  • min: the minimum of all base metric values for the specified context

  • sum: a sum of all base metric values for the specified context

  • count: a count of the number of base metric values for the specified context

AGGR_CTX

accepted forms are:

  • same: use the same context for both the aggregate metric and the base metric

  • function: use the function context for the aggregation

  • unit: use the translation unit context for the aggregation

  • program: use the whole program context for the aggregation

  • project: use the whole project context for the aggregation

EXPR

accepted forms are:

  • NUMBER: a number

  • list(EXPRS): a list of expressions

  • -EXPR: unary minus

  • ceil(EXPR): ceil

  • floor(EXPR): floor

  • max(EXPR,EXPR): max

  • min(EXPR,EXPR): min

  • round(EXPR): round

  • sign(EXPR): sign

  • sqr(EXPR): square

  • sqrt(EXPR): square root

  • EXPR_LHSBINOPEXPR_RHS: binary operator

  • EXPR_COND?:EXPR_ELSE: binary conditional operator

  • EXPR_COND?EXPR_THEN:EXPR_ELSE: conditional operator

  • ID_NAME:ID_SUBJECT: the metric expression has the metric name ID_NAME and subject ID_SUBJECT

  • ID: the metric expression is the metric name ID

BINOP

accepted forms are:

  • +: add

  • -: subtract

  • *: times

  • /: divide

  • %: remainder

  • &: bitwise and

  • |: bitwise or

  • ^: bitwise xor

  • ==: equal

  • !=: not equal

  • <: less than

  • >: greater than

  • <=: less than or equal to

  • >=: greater than or equal to

  • <<: bitwise left shift

  • >>: bitwise right shift

  • >=: greater than or equal to

  • &&: logical and

  • ||: logical or

  • ??: coalescing operator

EXPRS

accepted forms are:

  • EXPR,EXPRS: expressions

  • EXPR: expression

SUMMARY:

summery describing the metric.

Default:

-metrics={}

Types and constant names

Option -boolean_constants
-boolean_constants
-boolean_constants=NAME,...

Specify any defined Boolean constant.

NAME,…:

a set of Boolean constant names. Accepted members are:

  • NAME: a name for a Boolean constant.

Default:

-boolean_constants=true, false

Option -boolean_typenames
-boolean_typenames
-boolean_typenames=NAME,...

Specify type names used for Boolean values.

NAME,…:

a set of Boolean type names. Accepted members are:

  • NAME: a name for a Boolean type.

Default:

-boolean_typenames=bool

Option -typedef_naming
-typedef_naming
-typedef_naming={SCHEME, {{{BUILT_IN,...}, FMT},...}},...

Specify the builtin types that should always be used via a matching typedef.

The configuration’s content is a collection of named typedef naming schemes for builtin types.

SCHEME:

scheme identifier.

BUILT_IN,…:

built-in types. Accepted members are:

  • _Bool: _Bool;

  • __int128_t: __int128_t;

  • __uint128_t: __uint128_t;

  • bool: bool;

  • char: char;

  • char8_t: char8_t;

  • char16_t: char16_t;

  • char32_t: char32_t;

  • int: int;

  • long long: long long;

  • long: long;

  • short: short;

  • signed char: signed char;

  • unsigned char: unsigned char;

  • unsigned long long: unsigned long long;

  • unsigned long: unsigned long;

  • unsigned short: unsigned short;

  • unsigned: unsigned;

  • wchar_t: wchar_t;

  • double: double;

  • long double: long double;

  • float: float;

  • half: half;

  • void: void;

  • unsized_unsigned_integral: the following: unsigned, unsigned char, unsigned long, unsigned long long, unsigned short are the built-in unsized unsigned integral types;

  • unsized_signed_integral: the following: int, signed char, signed long, signed long long, signed short are the built-in unsized signed integral types;

  • unsized_floating: the following: double, float, half, long double are the built-in unsized floating point types;

  • unsized_complex_floating: the following: _Complex double, _Complex float, _Complex half, _Complex long double are the unsized complex floating point types;

FMT:

format (see the -fmt template typedef_naming_default_fmt) to specify the regular expression for matching the typedef name with fields:

bits

bit size of the built-in type;

bits0

two-digits bit size of the built-in.

Default:

-typedef_naming={misra,
    {{{unsized_unsigned_integral},
        "%{__misra_uint_fmt()}"},
      {{unsized_signed_integral},
        "%{__misra_sint_fmt()}"},
      {{unsized_floating},
        "%{__misra_float_fmt()}"},
      {{unsized_complex_floating},
        "%{__misra_complex_fmt()}"}}}
-typedef_naming+={misra_1,
    {{{"signed char"},
        "%{__misra_1_scint_fmt()}"},
      {{"unsigned char"},
        "%{__misra_1_ucint_fmt()}"},
      {{unsized_signed_integral},
        "%{__misra_1_siint_fmt()}"},
      {{unsized_unsigned_integral},
        "%{__misra_1_uiint_fmt()}"},
      {{unsized_floating},
        "%{__misra_1_float_fmt()}"},
      {{unsized_complex_floating},
        "%{__misra_1_complex_fmt()}"}}}
-typedef_naming+={lp1,
    {{{unsized_signed_integral},
        "%{__lp1_sint_fmt()}"},
      {{unsized_unsigned_integral},
        "%{__lp1_uint_fmt()}"},
      {{unsized_floating},
        "%{__lp1_float_fmt()}"},
      {{unsized_complex_floating},
        "%{__lp1_complex_fmt()}"}}}
-typedef_naming+={mp1,
    {{{char},
        "%{__mp1_char_fmt()}"},
      {{unsized_signed_integral},
        "%{__mp1_sint_fmt()}"},
      {{unsized_unsigned_integral},
        "%{__mp1_uint_fmt()}"},
      {{unsized_floating},
        "%{__mp1_float_fmt()}"},
      {{unsized_complex_floating},
        "%{__mp1_complex_fmt()}"}}}
-typedef_naming+={jpl,
    {{{unsized_signed_integral},
        "%{__jp1_sint_fmt()}"}, {{unsized_unsigned_integral},
        "%{__jp1_uint_fmt()}"},
      {{unsized_floating},
        "%{__jp1_float_fmt()}"},
      {{unsized_complex_floating},
        "%{__jp1_complex_fmt()}"}}}

Selectors

Option -area_selector
-area_selector
-area_selector={ID, AREA_MATCHER},...

Associates a selection identifier to an expression defining the matching report areas.

The configuration’s content is a collection of named selectors for report areas.

ID:

an area selection identifier.

AREA_MATCHER:

an expression defining the matching areas. Accepted forms are:

  • [+]AND_MATCHER: the area matches AND_MATCHER

  • -AND_MATCHER: the area does not match AND_MATCHER

  • [+]AND_MATCHER||AREA_MATCHER: either the area matches AND_MATCHER or it matches AREA_MATCHER

  • -AND_MATCHER||AREA_MATCHER: the area does not match AND_MATCHER but does match AREA_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the area matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the area matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (AREA_MATCHER): the area matches AREA_MATCHER

  • !BASIC_MATCHER: the area does not match BASIC_MATCHER

  • any(): any area matches

  • none(): no area matches

  • ^REGEX$: the message matches ^REGEX$

  • all_loc(LOC_MATCHER): all area’s locations matches LOC_MATCHER (see the -loc_selector global configuration)

  • any_loc(LOC_MATCHER): any area’s locations matches LOC_MATCHER (see the -loc_selector global configuration)

  • begin_loc(LOC_MATCHER): the area begin location matches LOC_MATCHER (see the -loc_selector global configuration)

  • end_loc(LOC_MATCHER): the area end location matches LOC_MATCHER (see the -loc_selector global configuration)

  • text(^REGEX$[,LINES_RANGE]): the text in top expansion location lines range relative to area defined by LINES_RANGE matches ^REGEX$. The default is begin+0..end+0

  • context(DECL_MATCHER): the context declaration matches DECL_MATCHER (see the -decl_selector global configuration)

  • decl(DECL_MATCHER): the declaration referred to in the area matches DECL_MATCHER (see the -decl_selector global configuration)

  • entity(ENTITY_MATCHER): the entity referred to in the area matches ENTITY_MATCHER (see the -entity_selector global configuration)

  • stmt(STMT_MATCHER): the statement or expression referred to in the area matches STMT_MATCHER (see the -stmt_selector global configuration)

  • kind(AREA_KIND[||AREA_KIND]*): the area kind one of the AREA_KIND

  • macro(MACRO_MATCHER): the macro referred to in the area matches MACRO_MATCHER (see the -macro_selector global configuration)

  • value(VALUE_MATCHER): the value for the area matches VALUE_MATCHER (see the -value_selector global configuration)

  • frame(FRAME_MATCHER): the frame generating the area matches FRAME_MATCHER (see the -frame_selector global configuration)

  • ID: the area matches the matcher associated to ID in the -area_selector global configuration

AREA_KIND

accepted forms are:

  • culprit: culprit

  • evidence: evidence

  • context: context

  • instantiation: instantiation

REGEX

accepted forms are:

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

LINES_RANGE

accepted forms are:

  • [begin±]NUMRANGE_SEP[end±]NUM: the range in the area location where the text matched by REGEX should be searched. begin is the first line of the area, and end is the last


Option -call_selector
-call_selector
-call_selector={ID, CALL_MATCHER},...

Associates a selection identifier to an expression defining the matching calls.

The configuration’s content is a collection of named selectors for macro and function calls.

ID:

a call selection identifier.

CALL_MATCHER:

an expression defining the matching calls. Accepted forms are:

  • [+]AND_MATCHER: the call matches AND_MATCHER

  • -AND_MATCHER: the call does not match AND_MATCHER

  • [+]AND_MATCHER||CALL_MATCHER: either the call matches AND_MATCHER or it matches CALL_MATCHER

  • -AND_MATCHER||CALL_MATCHER: the call does not match AND_MATCHER but does match CALL_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the call matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the call matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CALL_MATCHER): the call matches CALL_MATCHER

  • !BASIC_MATCHER: the call does not match BASIC_MATCHER

  • any(): any call matches

  • none(): no call matches

  • ^REGEX$: the fully qualified name of the callee matches ^REGEX$

  • all_arg(ARG_RANGE,STMT_MATCHER): for a call having all arguments with indices in the range ARG_RANGE that match STMT_MATCHER (note that the argument indices start at index 1 so that there is no element with index 0 and that negative range values are counted in reverse from the last argument down)

  • any_arg(ARG_RANGE,STMT_MATCHER): for a call having at least one argument with index in the range ARG_RANGE that matches STMT_MATCHER (note that the argument indices start at index 1 so that there is no element with index 0 and that negative range values are counted in reverse from the last argument down)

  • decl(DECL_MATCHER): the callee declaration matches DECL_MATCHER (see the -decl_selector global configuration)

  • entity(ENTITY_MATCHER): the callee declaration matches ENTITY_MATCHER (see the -entity_selector global configuration)

  • error_where(ERROR_WHERE): the call with error value in ERROR_WHERE)

  • impact(IMPACT): the call’s impact property is IMPACT

  • macro(MACRO_MATCHER): the call is expanded from a macro that matches MACRO_MATCHER (see the -macro_selector global configuration)

  • name(ID[||ID]*): the callee’s unqualified name is an identifier that matches one of the ID

  • node(ASTF[||ASTF]*): the call matches one of the AST functors

  • property(PROPERTY[||PROPERTY]*): the call property’s identifier is one of the PROPERTY

  • resource(RESOURCE_MATCHER): the call is referring to a resource that matches RESOURCE_MATCHER

  • return_type(TYPE_MATCHER): the call whose callee return type matches TYPE_MATCHER (see the -type_selector global configuration)

  • std(STDS_MATCHER): the standard used is STDS_MATCHER (see the -stds global configuration)

  • std_fname(ID[||ID]*): the callee’s unqualified name or called macro name matches one of the ID and is declared or defined in the standard library

  • stdlib(STDLIB[||STDLIB]*): select this call if the project standard library set contains one of the STDLIB (see the -stdlib global configuration)

  • stmt(STMT_MATCHER): the call expression is a statement matching STMT_MATCHER (see the -stds global configuration)

  • tag(TAG[||TAG]*): the call property’s tags matches one of the TAGs

  • type(TYPE_MATCHER): the call is a type that matches TYPE_MATCHER (see the -type_selector global configuration)

  • ID: the call matches the matcher associated to ID in -call_selector global configuration

STDLIB

accepted forms are:

  • posix: the project standard library posix

PROPERTY

accepted forms are:

  • const_pointee_read(POINTEE_RW[&&POINTEE_RW]*): indicate the read use for call arguments that correspond to parameters whose pointee types are const

  • const_pointee_write(POINTEE_RW[&&POINTEE_RW]*): indicate the write use for call arguments that correspond to parameters whose pointee types are const

  • data_kind(POS_MIN_MAX,TKIND): the call arguments or return in the specified index range POS_MIN_MAX have the specified data kind. Index 0 refers the return value, the indices of the arguments start from 1

  • errno[(MODE)]: if the argument is omitted or MODE is true, then, when an error occurs, the errno indicator will be set. If MODE is false, then the errno indicator is not set

  • error(ID[&&ID]*): function error is specified by ID

  • ignorable_result[(MODE)]: if the argument is omitted or MODE is true, then the call is considered as having an ignorable result. If MODE is false, then the call is considered as having a non-ignorable result

  • IMPACT: the call has impact IMPACT

  • impact(IMPACT): the call has impact IMPACT

  • malloc[(MODE)]: if the argument is omitted or MODE is true, then the call is considered as having the malloc property. If MODE is false, then the call is considered as not having the malloc property

  • math_err[(MODE)]: if the argument is omitted or MODE is true, then the call is considered as possibly setting the errno indicator and/or raising a floating-point exception if an error occurs according to the value of math_errhandling. If MODE is false, then the call is considered as not setting the errno indicator and/or raising a floating-point exception. non-const

  • noeffect: like pure but can also read volatile variable not triggering side effects. This is equivalent to impact(noeffect)

  • noreturn[(MODE)]: if the argument is omitted or MODE is true, then the call is considered to be non-returning. If MODE is false, then the call is considered to be returning

  • pointee_read(POINTEE_RW[&&POINTEE_RW]*): indicate the read use for call arguments that correspond to parameters whose pointee types are non-const

  • pointee_write(POINTEE_RW[&&POINTEE_RW]*): indicate the write use for call arguments that correspond to parameters whose pointee types are non-const

  • points_to(POINTS_TO_ITEM[&&POINTS_TO_ITEM]*): all the points_to properties must hold

  • resource(RESOURCE_ITEM[,RESOURCE_ITEM]*): indicates a set of property resources that must hold

  • returned([RETURNED[&&RETURNED]*]): indicates that the specified address arguments may be returned; address arguments not listed are never returned

  • tag(Id[&&Id]*): user-defined property tags

  • taken([TAKEN[&&TAKEN]*]): indicates that the specified address arguments may be stored in objects that persist after the function has ceased to exist (excluding the returned value); address arguments not listed are never taken

IMPACT

accepted forms are:

  • const: call is const. That is, it is assumed that the called function is const

  • fp_const: the floating-point environment is unchanged and the call is const

  • pure: call is pure. That is, it is assumed that the called function is pure

  • noeffect: a call to a function with no external side effect. That is, it is assumed that: there are no indirect calls; any throw is caught within the function; there are no calls to new, delete, a non-trivial constructor or a destructor; it does not write to a variable that is volatile or has static storage; and it does not read from a volatile variable that triggers a side effects

  • nothrow: a call to a function for which it is assumed that any thrown exceptions are caught within the function

  • any: the call can have any impact

REGEX

accepted forms are:

ARG_RANGE

accepted forms are:

  • MINRANGE_SEPMAX: range is from MIN to MAX or, if MIN and MAX are negative and the length is L, the range is from L + MIN + 1 to L + MAX + 1

  • RANGE_SEPNUM: range is all values equal or less than NUM or, if NUM is negative and the length is L, the range is all values equal or less than L + NUM + 1

  • NUMRANGE_SEP: range is all values equal or greater than NUM or, if NUM is negative and the length is L, the range is all values equal or greater than L + NUM + 1

  • NUM: range is the single value NUM or, if NUM is negative and the length is L, the value is L + NUM + 1

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option -asm_properties
-asm_properties
-asm_properties={ASM_MATCHER, {PROPERTY,...}},...

Specify properties of a gcc asm statement.

The configuration’s content is a list of asm specifications with properties.

ASM_MATCHER:

the node is an asm statement that matches ASM_MATCHER (see -stmt_selector).

PROPERTY:

asm property. Accepted forms are:

  • no_side_effect: asm has no side effects

  • read(BOOL3): indicate if memory is read

  • write(BOOL3): indicate if asm output arguments are written

BOOL3

accepted forms are:

  • always: always happens

  • maybe: might or might not happen

  • never: never happens


Option -default_asm_properties
-default_asm_properties
-default_asm_properties=PROP,...

Specify the default properties for gcc asm statements.

The configuration’s content is a set of properties.

PROP:

asm property.

Default:

-default_asm_properties="read(maybe)",
  "write(always)"

Option -comment_selector
-comment_selector
-comment_selector={ID, COMMENT_MATCHER},...

Associates a selection identifier to an expression defining the matching comments.

The configuration’s content is a collection of named selectors for comments.

ID:

a comment selection identifer.

COMMENT_MATCHER:

an expression defining the matching comments. Accepted forms are:

  • [+]AND_MATCHER: the comment matches AND_MATCHER

  • -AND_MATCHER: the comment does not match AND_MATCHER

  • [+]AND_MATCHER||COMMENT_MATCHER: either the comment matches AND_MATCHER or it matches COMMENT_MATCHER

  • -AND_MATCHER||COMMENT_MATCHER: the comment does not match AND_MATCHER but does match COMMENT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the comment matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the comment matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COMMENT_MATCHER): the comment matches COMMENT_MATCHER

  • !BASIC_MATCHER: the comment does not match BASIC_MATCHER

  • any(): any comment matches

  • none(): no comment matches

  • ^REGEX$: the comment text matches ^REGEX$

REGEX

accepted forms are:

Default:

-comment_selector={__document_any_comments,
    "^(?:\\n|.)+$"},
  {__eclair_rtag_comments,
    "^/[/\\*]\\s*-+E>\\s.*$"},
  {__doxygen_comments,
    "^(?ms)/(\\*(\\*|!)|/(/|!)).*$"},
  {__fall_through_empty_case_comments,
    "^(.*[fF]all[- ]?[tT]hr(ough|u)|.*FALL[- ]?THR(OUGH|U))(?s).*$"},
  {__empty_missing_else_comments,
    "^.*(empty[- ]else|EMPTY[- ]ELSE)(?s).*$"},
  {__empty_compound_else_comments,
    "^.*(empty[- ]else|EMPTY[- ]ELSE)(?s).*$"},
  {__document_cast_comments,
    "^(?:\\n|.)*\\b([Cc]ast|[Cc]onversion|[Cc]onvert|[Oo]verflow|[Ww]rap[p]?)(s|ed|ing)?\\b(?:\\n|.)*$"}

Option -replacer
-replacer
-replacer={ID, REGEX, REPLACER},...

Associates a replacer identifier to an expression defining the replacements. The replacement expression associated to first regular expression that matches the input (if any) is evaluated and returned. If no regular expression matches, the input is returned unmodified. Some identifiers have special uses:

canonical_path

is used to influence file canonical pathname generation.

The configuration’s content is a collection of named replacer definitions.

ID:

a replacer identifier.

REGEX:

a regular expression.

REPLACER:

an expression defining the action. Accepted forms are:

  • 'STRING': the replacement is STRING

  • STRINGREPLACER_NAMED_PARTS: the output is the concatenation of STRING (maximal prefix not including the %) character followed by the replacement specified by REPLACER_NAMED_PARTS

REPLACER_NAMED_PARTS

accepted forms are:

  • %{REPLACER_EXPR{}}REPLACER_PARTS: the output is the concatenation of the replacements specified by REPLACER_EXPR and REPLACER_PARTS

REPLACER_PIPE_EXPR

accepted forms are:

  • REPLACER_CAT_EXPR: the output is the replacement specified by REPLACER_CAT_EXPR

  • REPLACER_CAT_EXPR|REPLACER_PIPE_EXPR: the output is the replacement specified by REPLACER_PIPE_EXPR with input expression specified by REPLACER_CAT_EXPR

REPLACER_CAT_EXPR

accepted forms are:

  • REPLACER_EXPR: the output is the replacement specified by REPLACER_EXPR

  • REPLACER_EXPR|REPLACER_CAT_EXPR: the output is the replacement specified by REPLACER_EXPR concatenated with the replacement specified by REPLACER_CAT_EXPR

REPLACER_EXPR

accepted forms are:

  • $POS_NUMBER: the regular expression group POS_NUMBER

  • @POS_NUMBER: the expression argument POS_NUMBER

  • regquote(REPLACER_EXPR): quote all special regular expression characters in REPLACER_EXPR, so that the output text can be used as part of a regular expression

  • upcase(REPLACER_EXPR): replace all lowercase by uppercase in REPLACER_EXPR

  • downcase(REPLACER_EXPR): replace all uppercase by lowercase in REPLACER_EXPR

  • save(REPLACER_EXPR0,REPLACER_EXPR1): add REPLACER_EXPR1 to saved assoc list values for key REPLACER_EXPR0

  • tr(REPLACER_EXPR0,REPLACER_EXPR1,REPLACER_EXPR2): in REPLACER_EXPR0, replace each character in REPLACER_EXPR1by the corresponding character in REPLACER_EXPR2

  • replace(REPLACER_EXPR0,REPLACER_EXPR1,REPLACER_EXPR2): in REPLACER_EXPR0, replace every string REPLACER_EXPR1 by the string REPLACER_EXPR2

  • substr(REPLACER_EXPR0,REPLACER_EXPR1,REPLACER_EXPR2): the expression arguments REPLACER_EXPR1 and REPLACER_EXPR2 must evaluate to non-negative integers; then REPLACER_EXPR0 is replaced by the substring beginning at REPLACER_EXPR1 with length REPLACER_EXPR2

  • REPLACER_ID(REPLACER_EXPR0,REPLACER_EXPR1): replace text using replacer REPLACER_ID with arguments replacer expressions REPLACER_EXPR0 and REPLACER_EXPR1

  • 'STRING': the quoted string STRING

  • NUMBER: the number NUMBER

Default:

-replacer={__anydecl_document_repl, "^(?:\\n|.)+$", "%{$0}"}
-replacer+={__anydecl_comment_repl, "^//(.*)$", "%{$1} "},
  {__anydecl_comment_repl, "^/[*]((?:\\n|.)*)([*]/)$", "%{$1} "}
-replacer+={__function_document_repl, "^(?:\\n|.)+$", "%{$0}"}
-replacer+={__parameter_document_repl, "^(?:\\n|.)*$", "%{$0}"}
-replacer+={__function_comment_repl, "^//(.*)$", "%{$1} "},
  {__function_comment_repl, "^/[*]((?:\\n|.)*)([*]/)$", "%{$1} "}
-replacer+={__memory_reuse_comment_repl, "^//(.*)$", "%{$1} "},
  {__memory_reuse_comment_repl, "^/[*]((?:\\n|.)*)([*]/)$", "%{$1} "}
-replacer+={__asm_comment_repl, "^//(.*)$", "%{$1} "},
  {__asm_comment_repl, "^/[*]((?:\\n|.)*)([*]/)$", "%{$1} "}
-replacer+={__expr_comment_repl, "^//(.*)$", "%{$1} "},
  {__expr_comment_repl, "^/[*]((?:\\n|.)*)([*]/)$", "%{$1} "}
-replacer+={__fundefn_comment_repl, "^//(.+)$", "%{$1}"},
  {__fundefn_comment_repl, "^/[*]((?:\\n|.)+)([*]/)$", "%{$1}"}

Option -context_selector
-context_selector
-context_selector={ID, CONTEXT_MATCHER},...

Associates a selection identifier to an expression defining the matching contexts.

The configuration’s content is a collection of named selectors for node contexts.

ID:

a context selection identifier.

CONTEXT_MATCHER:

an expression defining the matching of a pair node-context where node is the current node and context is a sequence of ancestor/child pairs. Each matcher checks the input node-context pair and returns a revised pair. Accepted forms are:

  • OR_MATCHER: the context matches OR_MATCHER

  • OR_MATCHER##CTXT_MATCHER: the node-context matches OR_MATCHER that returns a revised node-context pair; CTXT_MATCHER matches the revised pair

OR_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the node-context matches AND_MATCHER

  • -AND_MATCHER: the node-context does not match AND_MATCHER

  • [+]AND_MATCHER||CTXT_MATCHER: either the node-context matches AND_MATCHER or it matches CTXT_MATCHER

  • -AND_MATCHER||CTXT_MATCHER: the node-context does not match AND_MATCHER but does match CTXT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node-context matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node-context matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CTXT_MATCHER): the node-context matches CTXT_MATCHER

  • !BASIC_MATCHER: the node-context does not match BASIC_MATCHER

  • any(): any node-context matches; the input pair is returned

  • none(): no node-context matches; the input pair is returned

  • any_child(): returns the pair ancestor-context1 where ancestor is the first ancestor in the context sequence and context1 is the rest

  • call(CALL_MATCHER): the node is a call that matches CALL_MATCHER (see the -call_selector global configuration). Returns the pair ancestor-context1 where ancestor is the first ancestor in the context sequence and context1 is the rest

  • call_child(CALL_MATCHER,CHILD[,CHILD_RANGE]): if ancestor/child is the first pair in context, then ancestor is a call that matches CALL_MATCHER and the child is of the form child_kind-index where either child_kind is arg and has an index in the range CHILD_RANGE, or child_kind matches CHILD (see the -call_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • capture(CTXT_MATCHER): the context matches CTXT_MATCHER; the matching sequence is saved and passed back to the caller

  • ccall(CALL_MATCHER): this searches the context up to the first ancestor/child pair where ancestor is a call; it succeeds if ancestor matches CALL_MATCHER (see the -call_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • cdecl(DECL_MATCHER): this searches the context up to the first ancestor/child pair where ancestor is a declaration; it succeeds if ancestor matches DECL_MATCHER (see the -decl_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • centity(ENTITY_MATCHER): this searches the context up to the first ancestor/child pair where ancestor is an entity declaration; it succeeds if ancestor matches ENTITY_MATCHER (see the -entity_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • cfunction(DECL_MATCHER): this searches the context up to the first ancestor/child pair where ancestor is a function declaration; it succeeds if ancestor matches DECL_MATCHER (see the -decl_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • class(CLASSES,CHILDREN: the first ancestor/child pair matches CLASSES and CHILDREN. Returns the pair ancestor-context1 where context1 is the rest of the context

  • cstmt(STMT_MATCHER): this searches the context up to the first ancestor/child pair where ancestor is a statement or expression; it succeeds if ancestor matches STMT_MATCHER (see the -stmt_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • decl(DECL_MATCHER): the node is a declaration that matches DECL_MATCHER (see the -decl_selector global configuration). Returns the pair ancestor-context1 where ancestor is the first ancestor in the context sequence and context1 is the rest

  • decl_child(DECL_MATCHER,CHILD): if ancestor/child is the first pair in context, then ancestor is a declaration that matches DECL_MATCHER and the child is of the form child_kind-index where either child_kind is arg and has an index in the range CHILD_RANGE, or child_kind matches CHILD (see the -decl_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • diff(CTXT_MATCHER_0,CTXT_MATCHER_1): the context matches CTXT_MATCHER_0 but does match CTXT_MATCHER_1

  • entity(ENTITY_MATCHER): the node is an entity that matches ENTITY_MATCHER (see the -entity_selector global configuration). Returns the pair ancestor-context1 where ancestor is the first ancestor in the context sequence and context1 is the rest

  • entity_child(ENTITY_MATCHER,CHILD): if ancestor/child is the first pair in context, then ancestor is an entity that matches ENTITY_MATCHER and the child is of the form child_kind-index where either child_kind is arg and has an index in the range CHILD_RANGE, or child_kind matches CHILD (see the -entity_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • rep(CTXT_MATCHER,POS_MIN_MAX): greedily consumes RANGE subsequences that match CTXT_MATCHER

  • requires_const_child(): the first ancestor in context requires a constant child; the input pair is returned

  • role(CTXT_ROLE[&&CTXT_ROLE]*): the sequences of ancestors and children in context have a role matching one of the CTXT_ROLEs; the input pair is returned

  • skip_to(CTXT_MATCHER_0,CTXT_MATCHER_1): the node-context pair is lazily matched against CTXT_MATCHER_0 until the current pair matches CTXT_MATCHER_1

  • std(STDS_MATCHER): the standard used is STDS_MATCHER (see the -stds global configuration); the input pair is returned

  • stmt(STMT_MATCHER): the node is a statement or expression that matches STMT_MATCHER (see the -stmt_selector global configuration). Returns the pair ancestor-context1 where ancestor is the first ancestor in the context sequence and context1 is the rest

  • stmt_child(STMT_MATCHER,CHILD): if ancestor/child is the first pair in context, then ancestor is a statement or expression that matches STMT_MATCHER and the child is of the form child_kind-index where either child_kind is arg and has an index in the range CHILD_RANGE, or child_kind matches CHILD (see the -stmt_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • type(TYPE_MATCHER): the node is a type that matches TYPE_MATCHER (see the -type_selector global configuration). Returns the pair ancestor-context1 where ancestor is the first ancestor in the context sequence and context1 is the rest

  • type_child(TYPE_MATCHER,CHILD): if ancestor/child is the first pair in context, then ancestor is a type that matches TYPE_MATCHER and the child is of the form child_kind-index where either child_kind is arg and has an index in the range CHILD_RANGE, or child_kind matches CHILD (see the -type_selector global configuration). Returns the pair ancestor-context1 where context1 is the rest of the context

  • unevaluated(): the first ancestor in context is unevaluated; the input pair is returned

  • ID: the context matches the matcher associated to ID in -context_selector global configuration

CHILD

accepted forms are:

  • any: any child

  • ID: ID is a nonterminal child of an AST node

CHILDREN

accepted forms are:

  • CHILD[||CHILD]*: the child one of CHILD

  • any: any child

CHILD_RANGE

accepted forms are:

  • variadic: the child is a variadic argument

  • POS_MIN_MAX: the child index is in the range indicated by POS_MIN_MAX

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

CLASS

accepted forms are:

  • ID: ID is a node class

CLASSES

accepted forms are:

  • IDCLASS[||CLASS]*: the class of the first ancestor is one of CLASS

CAST_KIND

accepted forms are:

  • ID: ID is a cast kind

DECL_BASE_TAG

accepted forms are:

  • any_decl: any declaration

  • any_redeclarable_template_decl: any redeclarable template declaration

  • any_class_template_spec_decl: any class template spec declaration

  • any_class_decl: any class declaration

  • any_declarator_decl: any declarator declaration

  • any_method: any method

  • any_function: any function

  • any_record_decl: any record declaration

  • any_value_decl: any value declaration

  • any_tag_decl: any tag declaration

  • any_named_decl: any named declaration

  • any_var_decl: any variable declaration

  • any_template_decl: any template declaration

  • any_type_decl: any type declaration

  • any_typedef_name_decl: any typedef name declaration

  • any_using_shadow_decl: any using shadow declaration

  • any_function_decl: any function declaration

  • any_function_defn: any function definition

  • any_class_decl: any class declaration

  • any_constructor: any constructor

  • any_conversion: any conversion

  • any_destructor: any destructor

  • any_method_decl: any method declaration

  • any_method_defn: any method definition

DECL_TAG

accepted forms are:

  • ASTF: any declaration functor ASTF is a tag

  • DECL_BASE_TAG: any DECL_BASE_TAG is a tag

OP_TAG

accepted forms are:

  • ASTF: the operator node functor is ASTF

  • ID: the operator is ID

  • member_select: member selection operator . or ->

  • member_deref: member dereference operator .* or ->*

  • addrof: addrof operator &

  • deref: dereference operator *

  • complex: complex operator imag or real

  • sign: sign operator + or -

  • bitwise: any bitwise operator

  • logical: any logical operator

  • post_incdec: post-increment or post-decrement operator

  • pre_incdec: pre-increment or pre-decrement operator

  • sizeof: sizeof operator

  • extension: the extension operator

  • multiplicative: multiplicative operator *, / or %

  • additive: additive operator + or -

  • shift: shift operator << or >>

  • relational: relational operator <, <=, > or >=

  • equality: equality operator == or !=

  • conditional: a conditional operator

  • assignment: any assignment operator

  • additive_assign: any additive assign operator

  • bitwise_assign: any bitwise assign operator

  • multiplicative_assign: any multiplicative assign operator

  • shift_assign: any shift assign operator

  • throw: throw operator

  • comma: comma operator

  • incdec: any increment or decrement operator

  • comparative: any equality or relational operator

  • arithmetic: any arithmetic operator

  • arithmetic_assign: any arithmetic assign operator

  • assignment: any assignment operator

  • mathematical: any mathematical operator

CTXT_ROLE

accepted forms are:

  • used: used

  • ignored: ignored

  • to_void: cast to void


Option -decl_selector
-decl_selector
-decl_selector={ID, DECL_MATCHER},...

Associates a selection identifier to an expression defining the matching declarations.

The configuration’s content is a collection of named selectors for declarations.

ID:

a declaration selection identifier.

DECL_MATCHER:

an expression defining the matching declaration. Accepted forms are:

  • [+]AND_MATCHER: the declaration matches AND_MATCHER

  • -AND_MATCHER: the declaration does not match AND_MATCHER

  • [+]AND_MATCHER||DECL_MATCHER: either the declaration matches AND_MATCHER or it matches DECL_MATCHER

  • -AND_MATCHER||DECL_MATCHER: the declaration does not match AND_MATCHER but does match DECL_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the declaration matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the declaration matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (DECL_MATCHER): the declaration matches DECL_MATCHER

  • !BASIC_MATCHER: the declaration does not match BASIC_MATCHER

  • any(): any declaration matches

  • none(): no declaration matches

  • ^REGEX$: the declaration is named and its fully qualified name matches ^REGEX$

  • abstract(): the declaration is a class that is abstract

  • access(ACCESS_SPEC[||ACCESS_SPEC]*): the declaration has one of the access specifiers ACCESS_SPECIFIER

  • all_child(DECL_MATCHER): for any declaration with inner declarations, all of these match DECL_MATCHER

  • all_param(MIN_MAX,DECL_MATCHER): for a function, all parameters with indices in the range MIN_MAX match DECL_MATCHER

  • ancestor(DECL_MATCHER): an ancestor declaration context matches DECL_MATCHER

  • ancestor_or_self(DECL_MATCHER): the declaration or an ancestor declaration context matches DECL_MATCHER

  • anonymous(): the declaration is anonymous

  • any_child(DECL_MATCHER): for any declaration with inner declarations, one of these match DECL_MATCHER

  • any_param(MIN_MAX,DECL_MATCHER): for a function, one of the parameters with indices in the range MIN_MAX match DECL_MATCHER

  • any_type_targ(MIN_MAX,TYPE_MATCHER): for a specialization, one of the template parameters with indices in the range MIN_MAX match TYPE_MATCHER

  • ast_field(NAME_ID,NAME_MATCHER): an ast field NAME_ID whose value matches NAME_MATCHER

  • bitfield_width(POS_MIN_MAX): the declaration is for a bit-field with length in the range POS_MIN_MAX

  • body_kind(FUNCTION_BODY_KIND): the declaration is a function definition with body kind FUNCTION_BODY_KIND

  • constexpr(): the declaration has the constexpr specifier

  • context(DECL_MATCHER): the declaration’s context matches DECL_MATCHER

  • copy_assignment(): the declaration is a method with the copy assignment operator

  • copy_constructor(): the declaration is a copy constructor

  • entity(ENTITY_MATCHER): the entity matches ENTITY_MATCHER (see the -entity_selector global configuration)

  • enum_implicit_type(): an enum whose underlying type is implicit

  • enum_scope(SCOPE_KIND[||SCOPE_KIND]*): a scoped enum declaration where the scope is one of SCOPE_KIND

  • explicit(): the declaration is a constructor/conversion and is explicit

  • extern_c: the function or variable declaration is wrapped by an extern “C” declaration

  • external_repeatable_defn(): the declaration is a repeatable function definition

  • forward_decl(): the declaration is a forward declaration

  • fqname('ID'[||'ID']*): the declaration’s fully qualified name matches one of the ID

  • implicit_access(): the declaration has implicit access

  • inherit(DECL_MATCHER,POS_MIN_MAX): the declaration inherits within level range POS_MIN_MAX matching DECL_MATCHER

  • initialized(): the declaration has an initialization

  • initializer(STMT_MATCHER): the declaration has an initializer expression that matches STMT_MATCHER

  • inline(): the declaration is inline

  • instance(INSTANCE_KIND): the declaration must have the instance kind INSTANCE_KIND

  • intrinsic(): a compiler intrinsic declaration

  • kind(ENTITY_KIND[||ENTITY_KIND]*): the entity has one of the entity ENTITY_KINDs

  • lexical_context(DECL_MATCHER): the declaration’s lexical context matches DECL_MATCHER

  • linkage(LINKAGE): the declaration has linkage LINKAGE

  • loc(LOC_MATCHER): the location of the declaration name matches LOC_MATCHER (see the -loc_selector global configuration)

  • move_assignment(): the declaration is a method with the move assignment operator

  • move_constructor(): the declaration is a move constructor

  • name(ID[||ID]*): the declaration’s name matches one of the ID

  • namespace(DECL_MATCHER): the declaration’s namespace matches DECL_MATCHER

  • node(ASTF[||ASTF]*): the declaration’s AST functor matches one of the ASTF

  • origin(ORIGIN): the declaration must have the named origin ORIGIN

  • outofline(): the declaration is out-of-line

  • override(DECL_MATCHER): the declaration is a method that overrides DECL_MATCHER

  • parameter_count(POS_MIN_MAX_L,POS_MIN_MAX_U): the declaration has parameters; the minimum number of parameters is in range POS_MIN_MAX_L and the maximum is in range POS_MIN_MAX_U

  • pattern(): the declaration must be a pattern

  • pod(): the declaration is a pod class

  • polymorphic_class(): the class is polymorphic

  • property(ID[||ID]*): the declaration has property ID. The property can be either a call property (see the -call_properties global configuration) or a declaration property (see the -decl_properties global configuration)

  • proto(PROTO_KIND): the declaration has a PRTO_KIND

  • record_kind(RECORD_KIND[||RECORD_KIND]*): the declaration is a record with one of the kinds RECORD_KIND

  • redeclared(): the declaration is a redeclaration

  • same_id_type(): the declaration and its type have the same unqualified names

  • std(STDS_MATCHER): the standard used is STDS_MATCHER (see the -stds global configuration)

  • storage_duration(STORAGE_DURATION): the declaration has storage duration STORAGE_DURATION

  • tentative_defn(): the declaration is a tentative definition

  • targ_count(MIN_MAX): the declaration has POS_MIN_MAX template arguments

  • type(TYPE_MATCHER): the declaration has a type that matches TYPE_MATCHER (see the -type_selector global configuration)

  • underlying_type(TYPE_MATCHER): the underlying type matches TYPE_MATCHER

  • variadic(): the declaration is variadic function

  • virtual_method(): the declaration is a virtual method

  • visibility(VISIBILITY): the declaration has visibility VISIBILITY

  • written_inline(): the declaration has inline specifier

  • written_storage(STORAGE_CLASS): the declaration has storage STORAGE_CLASS

  • ID: the declaration matches the matcher associated to ID in the -decl_selector global configuration

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

REGEX

accepted forms are:

ENTITY_KIND

accepted forms are:

  • class_template: a class template

  • constructor: a constructor

  • constructor_using_shadow: a constructor using shadow

  • conversion: a conversion

  • destructor: a destructor

  • enum: an enum

  • enum_constant: an enum constant

  • function: a function

  • function_template: a function template

  • label: a label

  • field: a field

  • method: a method

  • namespace: a namespace

  • namespace_alias: a namespace alias

  • param: a parameter

  • static_field: a static field

  • template_non_type_param: a template non type parameter

  • template_template_param: a template template parameter

  • template_type_param: a template type parameter

  • type_alias: a type alias

  • type_alias_template: a type alias template

  • typedef: a typedef

  • unresolved_using_typedef: an unresolved using typedef

  • unresolved_using_value: an unresolved using value

  • using: a using decl

  • using_directive: a using directive decl

  • using_shadow: a using shadow decl

  • var: a variable

LINKAGE

accepted forms are:

  • external: linkage is external

  • internal: linkage is internal

  • no_linkage: there is no linkage

  • has_linkage: linkage is internal or external

RECORD_KIND

accepted forms are:

  • class: class

  • struct: structure

  • union: union

ACCESS_SPEC

accepted forms are:

  • empty: access is empty or unspecified

  • public: access is declared public

  • protected: access is declared protected

  • private: access is private

STORAGE_CLASS

accepted forms are:

  • static: storage is static

  • auto: storage is auto

  • extern: storage is extern

  • register: storage is register

  • none: no storage

STORAGE_DURATION

accepted forms are:

  • static: storage duration is static

  • auto: storage duration is automatic

  • thread_local: storage is thread

INSTANCE_KIND

accepted forms are:

  • none: the declaration must not be a instance

  • partial_specialization: the declaration must be a partial specialization

  • specialization: the declaration must be a full specialization

  • instantiation: the declaration must be an instantiation

FUNCTION_BODY_KIND

accepted forms are:

  • default: default kind

  • delete: delete kind

  • implicit: implicit kind

  • unparsed: unparsed kind

  • written: written kind

ORIGIN

accepted forms are:

  • embedded: embedded declaration

  • standalone: standalone declaration

  • synthetic: synthetic declaration

VISIBILITY

accepted forms are:

  • program: program visibility

  • unit: unit visibility

  • function: function visibility

PROTO_KIND

accepted forms are:

  • written: a written prototype

  • no_written: no written prototype

  • k_and_r: k-and-r definition

DIRECTIVE

accepted forms are:

  • include: #include directive

  • define: #define directive

  • undef: #undef directive

RECORD_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the record matches AND_MATCHER

  • -AND_MATCHER: the record does not match AND_MATCHER

  • [+]AND_MATCHER||RECORD_MATCHER: either the record matches AND_MATCHER or it matches RECORD_MATCHER

  • -AND_MATCHER||RECORD_MATCHER: the record does not match AND_MATCHER but does match RECORD_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the record matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the record matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • kind(RECORD_KIND[||RECORD_KIND]*): the record kind is one of RECORD_KIND

  • polymorphic(): the record is polymorphic

  • defn(DECL_MATCHER): one of members in the definition matches DECL_MATCHER

  • record_defn_has_no_named_member(): declaration is a struct or union definition with no named member


Option -entity_selector
-entity_selector
-entity_selector={ID, ENTITY_MATCHER},...

Associates a selection identifier to an expression defining the matching entities.

The configuration’s content is a collection of named selectors for entities.

ID:

an entity selection identifier.

ENTITY_MATCHER:

an expression defining the matching entities. Accepted forms are:

  • [+]AND_MATCHER: the entity matches AND_MATCHER

  • -AND_MATCHER: the entity does not match AND_MATCHER

  • [+]AND_MATCHER||ENTITY_MATCHER: either the entity matches AND_MATCHER or it matches ENTITY_MATCHER

  • -AND_MATCHER||ENTITY_MATCHER: the entity does not match AND_MATCHER but does match ENTITY_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER[&&AND_MATCHER]*: the entity matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ENTITY_MATCHER): the entity matches ENTITY_MATCHER

  • !BASIC_MATCHER: the entity does not match BASIC_MATCHER

  • any(): any entity matches

  • none(): no entity matches

  • ^REGEX$: the fully qualified names of a declaration of the entity matches ^REGEX$

  • abstract(): the entity is a class that is abstract

  • access(ACCESS_SPEC[||ACCESS_SPEC]*): the entity has one of the access specifiers ACCESS_SPECIFIER

  • all_decl(DECL_MATCHER): all the entity declarations match DECL_MATCHER (see the -decl_selector global configuration)

  • ancestor(ENTITY_MATCHER): an ancestor declaration context for the entity matches ENTITY_MATCHER

  • ancestor_or_self(ENTITY_MATCHER): the entity itself or an ancestor declaration context for the entity matches ENTITY_MATCHER

  • anonymous(): the entity is anonymous

  • any_decl(DECL_MATCHER): at least one entity declaration matches DECL_MATCHER (see the -decl_selector global configuration)

  • any_type_targ(MIN_MAX,TYPE_MATCHER): for a specialization, one of the template parameters with indices in the range MIN_MAX match TYPE_MATCHER

  • bitfield_width(POS_MIN_MAX): the entity is a bit-field with length in the range POS_MIN_MAX

  • context(ENTITY_MATCHER): the entity’s context matches ENTITY_MATCHER

  • copy_assignment(): the entity is a method with the copy assignment operator

  • copy_constructor(): the entity is a copy constructor

  • extra_referenced(): the entity is referenced in a non-visible ways

  • fqname('ID'[||'ID']*): at least one entity declaration has a fully qualified name that matches one of the fully qualified names ID

  • inline(): the entity is inline

  • instance(INSTANCE_KIND): the declaration must have the instance kind INSTANCE_KIND

  • kind(ENTITY_KIND[||ENTITY_KIND]*): the entity has one of the entity ENTITY_KINDs

  • linkage(LINKAGE): entity has linkage LINKAGEs

  • move_assignment(): the entity is a move assignment operatort

  • move_constructor(): the entity is a move constructor

  • name(NAME[||NAME]*): at least one entity declaration has an unqualified name that matches one of the names NAME

  • namespace(ENTITY_MATCHER): the entity namespace matches ENTITY_MATCHER

  • override(DECL_MATCHER): the entity is a method that overrides DECL_MATCHER

  • pattern(): the entity must be a pattern

  • parameter_count(POS_MIN_MAX_L,POS_MIN_MAX_U): the entity has parameters; the minimum number of parameters is in range POS_MIN_MAX_L and the maximum is in range POS_MIN_MAX_U

  • record_kind(KIND[||RECORD_KIND]*): the entity is a record whose kind is one of the record kinds RECORD_KIND

  • storage_duration(STORAGE_DURATION): the entity has storage duration STORAGE_DURATION

  • targ_count(MIN_MAX): the entity has POS_MIN_MAX template arguments

  • visibility(VISIBILITY): the entity has visibility VISIBILITY

  • ID: the entity matches the matcher associated to ID in -entity_selector global configuration

REGEX

accepted forms are:

ACCESS_SPEC

accepted forms are:

  • empty: access is empty or unspecified

  • public: access is declared public

  • protected: access is declared protected

  • private: access is private

INSTANCE_KIND

accepted forms are:

  • none: the declaration must not be a instance

  • partial_specialization: the declaration must be a partial specialization

  • specialization: the declaration must be a full specialization

  • instantiation: the declaration must be an instantiation

STORAGE_CLASS

accepted forms are:

  • static: storage is static

  • auto: storage is auto

  • extern: storage is extern

  • register: storage is register

  • none: no storage

STORAGE_DURATION

accepted forms are:

  • static: storage duration is static

  • auto: storage duration is automatic

  • thread_local: storage is thread

VISIBILITY

accepted forms are:

  • program: program visibility

  • unit: unit visibility

  • function: function visibility

RECORD_KIND

accepted forms are:

  • class: class

  • struct: structure

  • union: union

ENTITY_KIND

accepted forms are:

  • class_template: a class template

  • constructor: a constructor

  • constructor_using_shadow: a constructor using shadow

  • conversion: a conversion

  • destructor: a destructor

  • enum: an enum

  • enum_constant: an enum constant

  • function: a function

  • function_template: a function template

  • label: a label

  • field: a field

  • method: a method

  • namespace: a namespace

  • namespace_alias: a namespace alias

  • param: a parameter

  • static_field: a static field

  • template_non_type_param: a template non type parameter

  • template_template_param: a template template parameter

  • template_type_param: a template type parameter

  • type_alias: a type alias

  • type_alias_template: a type alias template

  • typedef: a typedef

  • unresolved_using_typedef: an unresolved using typedef

  • unresolved_using_value: an unresolved using value

  • using: a using decl

  • using_directive: a using directive decl

  • using_shadow: a using shadow decl

  • var: a variable

LINKAGE

accepted forms are:

  • external: linkage is external

  • internal: linkage is internal

  • no_linkage: there is no linkage

  • has_linkage: linkage is internal or external


Option -file_tag
-file_tag
-file_tag={FILE_TAG, FILE_MATCHER},...

Assign tags to the files.

The configuration’s content is an ordered list of pairs ([DOMAIN:]FILE_TAG, FILE_MATCHER) combining a file tag with a file matcher. The tag paired with the first file matcher that matches the file name is assigned to that file for the specified domain (or the empty domain if it is not specified); no tag is assigned if there are no matching file matchers.

FILE_TAG:

the file’s tag.

FILE_MATCHER:

for matching the file. Accepted forms are:

  • [+]AND_MATCHER: the file matches AND_MATCHER

  • -AND_MATCHER: the file does not match AND_MATCHER

  • [+]AND_MATCHER||FILE_MATCHER: either the file matches AND_MATCHER or it matches FILE_MATCHER

  • -AND_MATCHER||FILE_MATCHER: the file does not match AND_MATCHER but does match FILE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the file matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the file matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (FILE_MATCHER): the file matches FILE_MATCHER

  • !BASIC_MATCHER: the file does not match BASIC_MATCHER

  • any(): any file matches

  • none(): no files matches

  • ^REGEX$: the file name matches ^REGEX$

  • kind(FILE_KIND[||FILE_KIND]*): the file has one of the kind FILE_KINDs

  • public(): the file is a public API file; by default the set of public API files includes all system headers; the set may be modified using the -public_files global configuration

  • std(): the file is part of the standard library

  • ID: the file has tag ID

REGEX

accepted forms are:

FILE_KIND

accepted forms are:

  • internal: an ECLAIR internal file

  • main_file: the main source file for the unit

  • object: an object file

  • project: the project as a whole

  • pseudo: a non file source (e.g. generated from compiler command line or from token pasting)

  • system: a system header file

  • user: a user header file

Default:

-file_tag={external, "kind(system||extern_c_system)||^([A-Z]:)?/.*$"},
  {project_files, "kind(main_file||user||object||project)&&!^([A-Z]:)?/.*$"},
  {pseudo, "kind(pseudo)"},
  {main, "kind(main_file)"},
  {header, "kind(user||system||extern_c_system)"}

Option -frame_selector
-frame_selector
-frame_selector={ID, FRAME_MATCHER},...

Associates a selection identifier to an expression defining the matching frames.

The configuration’s content is a collection of named selectors for frames.

ID:

a frame selection identifier.

FRAME_MATCHER:

an expression defining the matching frames. Accepted forms are:

  • [+]AND_MATCHER: the frame matches AND_MATCHER

  • -AND_MATCHER: the frame does not match AND_MATCHER

  • [+]AND_MATCHER||FRAME_MATCHER: either the frame matches AND_MATCHER or it matches FRAME_MATCHER

  • -AND_MATCHER||FRAME_MATCHER: the frame does not match AND_MATCHER but does match FRAME_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the frame matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the frame matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (FRAME_MATCHER): the frame matches FRAME_MATCHER

  • !BASIC_MATCHER: the frame does not match BASIC_MATCHER

  • any(): any frame matches

  • none(): no frame matches

  • main(FILE_MATCHER): the main file matches FILE_MATCHER (see the -file_tag global configuration)

  • target(FILE_MATCHER): the target file matches FILE_MATCHER (see the -file_tag global configuration)

  • kind(FRAME_KIND[||FRAME_KIND]*): the frame has one of the kind FRAME_KINDs

  • std(STD_MATCHER): the unit frame has a standard that matches STD_MATCHER (see the -stds global configuration)

  • re(REGEX): the command frame has a command line that matches REGEX

FRAME_KIND

accepted forms are:

  • unit: unit analysis frame

  • program: program analysis frame

  • project: project analysis frame

  • object: object analysis frame

REGEX

accepted forms are:


Option -loc_selector
-loc_selector
-loc_selector={ID, LOC_MATCHER},...

Associates a selection identifier to an expression defining the matching location.

The configuration’s content is a collection of named selectors for locations.

ID:

a location selection identifier.

LOC_MATCHER:

an expression defining the matching locations. Accepted forms are:

  • [+]AND_MATCHER: the location matches AND_MATCHER

  • -AND_MATCHER: the location does not match AND_MATCHER

  • [+]AND_MATCHER||LOC_MATCHER: either the location matches AND_MATCHER or it matches LOC_MATCHER

  • -AND_MATCHER||LOC_MATCHER: the location does not match AND_MATCHER but does match LOC_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the location matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the location matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (LOC_MATCHER): the location matches LOC_MATCHER

  • !BASIC_MATCHER: the location does not match BASIC_MATCHER

  • any(): any location matches

  • none(): no location matches

  • file(FILE_TAG): the location’s file matches FILE_TAG (see the -file_tag global configuration)

  • line(POS_MIN_MAX): the location line number is within range POS_MIN_MAX

  • top(LOC_MATCHER): the top expansion location matches LOC_MATCHER

  • begin_exp(LOC_MATCHER): direct expansion begin location matches LOC_MATCHER

  • end_exp(LOC_MATCHER): direct expansion end location matches LOC_MATCHER

  • any_exp(LOC_MATCHER): some expansion location matches LOC_MATCHER

  • all_exp(LOC_MATCHER): all expansion locations match LOC_MATCHER

  • any_begin_exp(LOC_MATCHER): some expansion begin location matches LOC_MATCHER

  • all_begin_exp(LOC_MATCHER): all expansion begin locations match LOC_MATCHER

  • any_end_exp(LOC_MATCHER): some expansion end location matches LOC_MATCHER

  • all_end_exp(LOC_MATCHER): all expansion end locations match LOC_MATCHER

  • text(^REGEX$[,LINES_RANGE]): the text in lines range relative to location defined by LINES_RANGE matches ^REGEX$. The default is0..0

  • macro(MACRO_MATCHER): the location is at an expansion of a macro that matches MACRO_MATCHER (see the -macro_selector global configuration)

  • ID: the location matches the matcher associated to ID in the -loc_selector global configuration

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

LINES_RANGE

accepted forms are:

  • [begin±]NUMRANGE_SEP[end±]NUM: the range in the area location where the text matched by REGEX should be searched. begin is the first line of the area, and end is the last


Option -macro_selector
-macro_selector
-macro_selector={ID, MACRO_MATCHER},...

Associates a selection identifier to an expression defining the matching macros.

The configuration’s content is a collection of named selectors for macros.

ID:

a macro selection identifier.

MACRO_MATCHER:

an expression defining the matching macros. Accepted forms are:

  • [+]AND_MATCHER: the macro matches AND_MATCHER

  • -AND_MATCHER: the macro does not match AND_MATCHER

  • [+]AND_MATCHER||MACRO_MATCHER: either the macro matches AND_MATCHER or it matches MACRO_MATCHER

  • -AND_MATCHER||MACRO_MATCHER: the macro does not match AND_MATCHER but does match MACRO_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the macro matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the macro matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (MACRO_MATCHER): the macro matches MACRO_MATCHER

  • !BASIC_MATCHER: the macro does not match BASIC_MATCHER

  • any(): any macro matches

  • none(): no macro matches

  • ^REGEX$: the macro name matches ^REGEX$

  • body(^REGEX$): the body’s normalized text (that is, a string where the parsed tokens are separated by a single space character) matches ^REGEX$

  • function_like(): the macro kind is function-like

  • guard(): the macro is used as a guard

  • loc(LOC_MATCHER): the macro definition location matches LOC_MATCHER (see the -loc_selector global configuyration)

  • name(ID[||ID]*): the macro’s name matches one of the ID

  • parameters(POS_MIN_MAX): the macro is function-like and the number of its parameters is in the range POS_MIN_MAX

  • same_id_body(): the macro body is the macro name; for example: #define x x or #define x() x

  • used(): the macro is used

  • variadic(): the macro is variadic

  • ID: the macro matches the matcher associated to ID in -macro_selector global configuration

REGEX

accepted forms are:


Option -name_selector
-name_selector
-name_selector={ID, NAME_MATCHER},...

Associates a selection identifier to an expression defining the matching names.

The configuration’s content is a collection of named selectors for names.

ID:

a name selection identifier.

NAME_MATCHER:

an expression defining the matching names. Accepted forms are:

  • [+]AND_MATCHER: the name matches AND_MATCHER

  • -AND_MATCHER: the name does not match AND_MATCHER

  • [+]AND_MATCHER||NAME_MATCHER: either the name matches AND_MATCHER or it matches NAME_MATCHER

  • -AND_MATCHER||NAME_MATCHER: the name does not match AND_MATCHER but does match NAME_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the name matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the name matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NAME_MATCHER): the name matches NAME_MATCHER

  • !BASIC_MATCHER: the name does not match BASIC_MATCHER

  • any(): any name matches

  • none(): no name matches

  • ^REGEX$: the name matches ^REGEX$

  • name(ID): the name matches ID

  • replace_vocabulary(REPL): if vocabulary options are supported, then, after transforming the name using REPL, the transformed name satisfies criteria defined using the supplied dictionaries, word files and associated configuration options

  • vocabulary(): if vocabulary options are supported, the name satisfies criteria defined using the supplied dictionaries, word files and associated configuration options

  • ID: the name matches the matcher associated to ID in the -name_selector global configuration

REGEX

accepted forms are:


Option -option_selector
-option_selector
-option_selector={ID, OPTION_MATCHER},...

Associates a selection identifier to an expression defining the matching options.

The configuration’s content is a collection of named selectors for options.

ID:

a option selection identifier.

OPTION_MATCHER:

an expression defining the matching options. Accepted forms are:

  • [+]AND_MATCHER: the option matches AND_MATCHER

  • -AND_MATCHER: the option does not match AND_MATCHER

  • [+]AND_MATCHER||OPTION_MATCHER: either the option matches AND_MATCHER or it matches OPTION_MATCHER

  • -AND_MATCHER||OPTION_MATCHER: the option does not match AND_MATCHER but does match OPTION_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the option matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the option matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (OPTION_MATCHER): the option matches OPTION_MATCHER

  • !BASIC_MATCHER: the option does not match BASIC_MATCHER

  • any(): any option matches

  • none(): no option matches

  • tag(NAME_MATCHER): the tag is named and its name matches NAME_MATCHER (see the -name_selector global configuration)

  • arg(POS_NUM,^REGEX$): the argument at position POS_NUM matches ^REGEX$

  • tool(TOOL_TAG): the tool is named and its name matches TOOL_TAG (see the -tool_tag global configuration)

REGEX

accepted forms are:


Option -service_selector
-service_selector
-service_selector={ID, SERVICE_MATCHER},...

Associates a selection identifier to an expression defining the matching services.

The configuration’s content is a collection of named selectors for services.

ID:

a service selection identifier.

SERVICE_MATCHER:

an expression defining the matching services. Accepted forms are:

  • [+]AND_MATCHER: the service matches AND_MATCHER

  • -AND_MATCHER: the service does not match AND_MATCHER

  • [+]AND_MATCHER||SERVICE_MATCHER: either the service matches AND_MATCHER or it matches SERVICE_MATCHER

  • -AND_MATCHER||SERVICE_MATCHER: the service does not match AND_MATCHER but does match SERVICE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the service matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the service matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SERVICE_MATCHER): the service matches SERVICE_MATCHER

  • !BASIC_MATCHER: the service does not match BASIC_MATCHER

  • any(): any service matches

  • none(): no service matches

  • ^REGEX$: the service id matches ^REGEX$

  • ID: the service identifier

  • tag(ID): the service tag

  • ID: the service matches the matcher associated to ID in -service_selector global configuration

REGEX

accepted forms are:


Option -stds
-stds
-stds={ID, STD_MATCHER},...

Specify the standard.

The configuration’s content is a collection of named selectors for standards.

ID:

a standard selection identifier.

STD_MATCHER:

an expression defining the matching standards. Accepted forms are:

  • [+]AND_MATCHER: the standard matches AND_MATCHER

  • -AND_MATCHER: the standard does not match AND_MATCHER

  • [+]AND_MATCHER||STD_MATCHER: either the standard matches AND_MATCHER or it matches STD_MATCHER

  • -AND_MATCHER||STD_MATCHER: the standard does not match AND_MATCHER but does match STD_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the standard matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the standard matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (STD_MATCHER): the standard matches STD_MATCHER

  • !BASIC_MATCHER: the standard does not match BASIC_MATCHER

  • any(): any standard matches

  • none(): no standard matches

  • STD: the standard is STD

  • ID: the node matches the matcher associated to ID in -stds global configuration

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-stds={c, c90||c95||c99||c11||c18}, {c++, c++98||c++03||c++11||c++14||c++17||c++20||c++23}, {c90_, c90||c95||c99||c11||c18}, {c95_, c95||c99||c11||c18}, {c99_, c99||c11||c18}, {c11_, c11||c18}, {c18_, c18}, {cxx98_, c++98||c++03||c++11||c++14||c++17||c++20||c++23}, {cxx03_, c++03||c++11||c++14||c++17||c++20||c++23}, {cxx11_, c++11||c++14||c++17||c++20||c++23}, {cxx14_, c++14||c++17||c++20||c++23}, {cxx17_, c++17||c++20||c++23}, {cxx20_, c++20||c++23}, {cxx23_, c++23}

Option -stmt_selector
-stmt_selector
-stmt_selector={ID, STMT_MATCHER},...

Associates a selection identifier to an expression defining the matching expression and statement nodes.

The configuration’s content is a collection of named selectors for expression and statements.

ID:

a statement and expression selection identifier.

STMT_MATCHER:

an expression defining the matching statement and expression nodes. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||STMT_MATCHER: either the node matches AND_MATCHER or it matches STMT_MATCHER

  • -AND_MATCHER||STMT_MATCHER: the node does not match AND_MATCHER but does match STMT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (STMT_MATCHER): the node matches STMT_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • all_stmt(ID,ARG_RANGE,STMT_MATCHER): for a statement child ID (which should have a list of statements or expressions), all elements with indices in the range ARG_RANGE match STMT_MATCHER (note that the argument indices start at index 1 so that there is no element with index 0 and that negative range values are counted in reverse from the last argument down, e.g., -1 identifies the last argument)

  • any_stmt(ID,ARG_RANGE,STMT_MATCHER): for a statement child ID (which should have a list of statements or expressions), an element with index in the range ARG_RANGE matches STMT_MATCHER (note that the argument indices start at index 1 so that there is no element with index 0 and that negative range values are counted in reverse from the last argument down, e.g., -1 identifies the last argument)

  • asm(ASM_MATCHER): the node is a gcc asm statement matching ASM_MATCHER

  • ast_field(NAME_ID,NAME_MATCHER): an ast field NAME_ID whose value matches NAME_MATCHER

  • attribute(ATTRIBUTE[||ATTRIBUTE]*): the node a statement or expression has an attribute that is one of the ATTRIBUTE values

  • any_base(Stmt_MATCHER): the expression must have at least one address base that matches STMT_MATCHER

  • begin(LOC_MATCHER): the initial location matches LOC_SELECTOR

  • call(CALL_MATCHER): the node must be a call expression matching CALL_MATCHER

  • callee(CALL_MATCHER): the node must evaluate to a function declaration matching CALL_MATCHER

  • cast(CAST_MATCHER): the node is a cast matching CAST_MATCHER

  • child(ID[||ID]*,STMT_MATCHER): there is a child matching STMT_MATCHER for a statement child that matches one of the ID

  • constant_initializer(): the node is a constant initializer

  • definitely_in(RANGE): the node has a value definitely in range RANGE

  • empty_child(ID): the node has child ID that is empty

  • end(LOC_MATCHER): the initial location matches LOC_SELECTOR

  • evaluatable(): the node is a constant expression

  • expr(): the node is an expression

  • f151_assign(): the node is an f151_assign expression

  • ice(): the node is an integer constant expression

  • inexact_literal(): the node is an inexact floating-point literal

  • kind(ID[||ID]*): the node is an expression whose ast node has a kind that is one of the ID values

  • literal(LITERAL_MATCHER): the node is a literal expression matching LITERAL_MATCHER

  • lvalue(): the node is an lvalue expression

  • macro(MACRO_MATCHER): the node is the full expansion of a macro and matches MACRO_MATCHER (see the -macro_selector global configuration)

  • misra_boolean(): the node is a MISRA Boolean typed expression. See page 118 of MISRA-C:2004 [62] for a definition of effectively Boolean

  • misra_character(): the node is a MISRA character typed expression

  • misra_enum(): the node is a MISRA enum typed expression

  • misra_integer(): the node is a MISRA integer typed expression

  • misra_kind(MKIND): the node is MKIND

  • name(ID[||ID]*): the statement’s name matches one of the ID

  • node(ASTF[||ASTF]*): the node matches one of the AST functors

  • nullptr(): an expression with a nullptr builtin type or a null_to_pointer explicit cast expression

  • operator(ID[||ID]*): the node is an expression whose main operator matches one of the ID operators or operator categories

  • possibly_in(RANGE): the node has a value possibly in range RANGE

  • pure_decl(): the statement is a declaration that does not have any initialization

  • ref(DECL_MATCHER): the node is an expression referring to a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • rvalue(): the node is an rvalue expression

  • skip(STMT_MATCHER0,STMT_MATCHER1): the node, possibly wrapped with expressions matching STMT_MATCHER0, matches STMT_MATCHER1 (note that that STMT_MATCHER0 is always checked before STMT_MATCHER1)

  • std(STDS_MATCHER): the standard used is STDS_MATCHER (see the -stds global configuration)

  • syntactic(): the node is syntactic

  • type(TYPE_MATCHER): the node is an expression with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • wrapped(STMT_MATCHER0,STMT_MATCHER1): the node, possibly wrapped with expressions matching STMT_MATCHER0, matches STMT_MATCHER1 (note that the unwrapping is lazy so that STMT_MATCHER1 is always checked before STMT_MATCHER0)

  • ID: the node matches the matcher associated to ID in -stmt_selector global configuration

MKIND

accepted forms are:

  • mc2_complex: a MISRA-C:2004 complex expression (see page 49 MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: a MISRA C:2012 composite expression (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: a MISRA C++:2008 cvalue expression (see page 66 of MISRA C++:2008 [64] , Section 6.5.0)

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

LITERAL_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the literal matches AND_MATCHER

  • -AND_MATCHER: the literal does not match AND_MATCHER

  • [+]AND_MATCHER||LITERAL_MATCHER: either the literal matches AND_MATCHER or it matches LITERAL_MATCHER

  • -AND_MATCHER||LITERAL_MATCHER: the literal does not match AND_MATCHER but does match LITERAL_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the literal matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the literal matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • node(ASTF[||ASTF]*): the literal matches one of the AST functors

  • kind(LIT_KIND[||LIT_KIND]*): the literal kind is one of LIT_KIND

  • ^REGEX$: the literal text matches ^REGEX$

ASM_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the asm matches AND_MATCHER

  • -AND_MATCHER: the asm does not match AND_MATCHER

  • [+]AND_MATCHER||ASM_MATCHER: either the asm matches AND_MATCHER or it matches ASM_MATCHER

  • -AND_MATCHER||ASM_MATCHER: the asm does not match AND_MATCHER but does match ASM_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the asm matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the asm matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • is_volatile(): the asm is volatile

  • writes_memory(): the asm writes to memory

CAST_MATCHER

accepted forms are:

  • [+]AND_CAST_MATCHER: the cast matches AND_CAST_MATCHER

  • -AND_CAST_MATCHER: the cast does not match AND_CAST_MATCHER

  • [+]AND_CAST_MATCHER||CAST_MATCHER: either the cast matches AND_CAST_MATCHER or it matches CAST_MATCHER

  • -AND_CAST_MATCHER||CAST_MATCHER: the cast does not match AND_CAST_MATCHER but does match CAST_MATCHER

AND_CAST_MATCHER

accepted forms are:

  • BASIC_CAST_MATCHER: the cast matches BASIC_CAST_MATCHER

  • BASIC_CAST_MATCHER&&AND_CAST_MATCHER: the cast matches BASIC_CAST_MATCHER and AND_CAST_MATCHER

BASIC_CAST_MATCHER

accepted forms are:

  • class(CAST_CLASS[||CAST_CLASS]*): the cast matches one of the cast class CAST_CLASS

  • from(type(TYPE_MATCHER)): the cast must be from an expression with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • from(expr(STMT_MATCHER)): the cast must be from an expression matching STMT_MATCHER

  • to(type(TYPE_MATCHER)): the cast must be to a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • kind(KIND[||KIND]*): the cast kind is one of ID

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

ATTRIBUTE

accepted forms are:

  • fallthrough: fallthrough

REGEX

accepted forms are:

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

ARG_RANGE

accepted forms are:

  • MINRANGE_SEPMAX: range is from MIN to MAX or, if MIN and MAX are negative and the length is L, the range is from L + MIN + 1 to L + MAX + 1

  • RANGE_SEPNUM: range is all values equal or less than NUM or, if NUM is negative and the length is L, the range is all values equal or less than L + NUM + 1

  • NUMRANGE_SEP: range is all values equal or greater than NUM or, if NUM is negative and the length is L, the range is all values equal or greater than L + NUM + 1

  • NUM: range is the single value NUM or, if NUM is negative and the length is L, the value is L + NUM + 1

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class


Option -report_selector
-report_selector
-report_selector={ID, REPORT_MATCHER},...

Associates a selection identifier to an expression defining the matching reports.

The configuration’s content is a collection of named selectors for reports.

ID:

a report selection identifier.

REPORT_MATCHER:

an expression defining the matching reports. Accepted forms are:

  • [+]AND_MATCHER: the report matches AND_MATCHER

  • -AND_MATCHER: the report does not match AND_MATCHER

  • [+]AND_MATCHER||REPORT_MATCHER: either the report matches AND_MATCHER or it matches REPORT_MATCHER

  • -AND_MATCHER||REPORT_MATCHER: the report does not match AND_MATCHER but does match REPORT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the report matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the report matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (REPORT_MATCHER): the report matches REPORT_MATCHER

  • !BASIC_MATCHER: the report does not match BASIC_MATCHER

  • any(): any report matches

  • none(): no report matches

  • category(REGEX): the report category matches REGEX; note that the category depends on the service and it is reported between square brackets only if its value is non-empty; see the service descriptions for more information about this field

  • tag(ID): at least one report tag is ID

  • kind(REPORT_KIND): the report kind

  • service(SERVICE_MATCHER): the reporting service matches the SERVICE_MATCHER (see the -service_selector global configuration)

  • first_area(AREA_MATCHER): the first area matches the AREA_MATCHER (see the -area_selector global configuration)

  • all_area(AREA_MATCHER): all the areas match AREA_MATCHER (see -area_selector global configuration)

  • any_area(AREA_MATCHER): at least one of the areas matches AREA_MATCHER (see the -area_selector global configuration)

  • ID: the report matches the matcher associated to ID in -report_selector global configuration

REPORT_KIND

accepted forms are:

  • error: error report

  • violation: violation report

  • caution: caution report

  • information: information report

  • metric: metric report

REGEX

accepted forms are:


Option -tool_tag
-tool_tag
-tool_tag={TOOL_TAG, TOOL_MATCHER},...

Assign tags to the project tools.

The configuration’s content is an ordered list of pairs ([DOMAIN:]TOOL_TAG, TOOL_MATCHER) combining a tool tag with a tool matcher. The tag paired with the first tool matcher that matches the tool specification is assigned to that tool; no tag is assigned if there are no matching tool matchers.

TOOL_TAG:

the tool’s tag.

TOOL_MATCHER:

tool matcher. Accepted forms are:

  • [+]AND_MATCHER: the tool matches AND_MATCHER

  • -AND_MATCHER: the tool does not match AND_MATCHER

  • [+]AND_MATCHER||TOOL_MATCHER: either the tool matches AND_MATCHER or it matches TOOL_MATCHER

  • -AND_MATCHER||TOOL_MATCHER: the tool does not match AND_MATCHER but does match TOOL_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the tool matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the tool matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (TOOL_MATCHER): the tool matches TOOL_MATCHER

  • !BASIC_MATCHER: the tool does not match BASIC_MATCHER

  • any(): any tool matches

  • none(): no tools matches

  • language(LANGUAGE[||LANGUAGE]*): the tool is for one of the LANGUAGEs

  • std(STD_MATCHER): the tool uses a standard that matches STD_MATCHER standard (see the -stds global configuration)

  • tool(FILE_MATCHER): the tool’s file matches FILE_MATCHER (see the -file_tag global configuration)

  • version(REGEX): the tool’s version matches REGEX

  • ID: the tool has tag ID

LANGUAGE

accepted forms are:

  • c: the C language

  • c++: the C++ language

REGEX

accepted forms are:

Default:

-tool_tag={}

Option -type_selector
-type_selector
-type_selector={ID, TYPE_MATCHER},...

Associates a selection identifier to an expression defining the matching types.

The configuration’s content is a collection of named selectors for types.

ID:

type selection identifier.

TYPE_MATCHER:

an expression defining the matching types. Accepted forms are:

  • [+]AND_MATCHER: the type matches AND_MATCHER

  • -AND_MATCHER: the type does not match AND_MATCHER

  • [+]AND_MATCHER||TYPE_MATCHER: either the type matches AND_MATCHER or it matches TYPE_MATCHER

  • -AND_MATCHER||TYPE_MATCHER: the type does not match AND_MATCHER but does match TYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the type matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the type matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (TYPE_MATCHER): the type matches TYPE_MATCHER

  • !BASIC_MATCHER: the type does not match BASIC_MATCHER

  • any(): any type matches

  • none(): no type matches

  • ^REGEX$: the type is named and the fully qualified name matches ^REGEX$

  • address(TYPE_MATCHER): the type is a pointer or reference and its addressed type matches TYPE_MATCHER

  • all_param(RANGE,TYPE_MATCHER): the type is a function where all parameters in range RANGE match TYPE_MATCHER

  • anonymous(): the type is unnamed

  • any_param(RANGE,TYPE_MATCHER): the type is a function where any parameter in range RANGE matches TYPE_MATCHER

  • any_inheritance(TYPE_MATCHER): the type is a class that inherits from a type that matches TYPE_MATCHER

  • arithmetic(): the type is arithmetic

  • array(TYPE_MATCHER): the type is an array of a type that matches TYPE_MATCHER

  • array_kind(ARRAY_KIND): the type is an array with kind is ARRAY_KIND

  • array_mod(ARRAY_SIZE_MOD): the type is an array with size modifier ARRAY_SIZE_MOD

  • array_qual(TYPE_QUALIFIER): the type is an array with qualification TYPE_QUALIFIER (Note: the presence of the _Atomic qualifier should be checked with the node(atomic) matcher)

  • array_size(POS_MIN_MAX): the type is an array with size in range POS_MIN_MAX

  • bitfield_signedness(BIT_SIGNEDNESS): the bitfield type has signedness BIT_SIGNEDNESS

  • builtin(BUILTIN): the type is the builtin BUILTIN

  • call(CALL_MATCHER): the type is a call to a function that matches CALL_MATCHER

  • canonical(TYPE_MATCHER): the input term’s canonical type matches TYPE_MATCHER

  • child(ID[||ID]*,TYPE_MATCHER): there is a child matching TYPE_MATCHER for a type child that matches one of the ID

  • desugar(TYPE_MATCHER): the fully desugared type matches TYPE_MATCHER

  • desugar_to(TYPE_MATCHER): the type is desugared step-by-step from the outer functor to the innermost type until there is a match with TYPE_MATCHER

  • enum_underlying_type(TYPE_MATCHER): the underlying type is an enum that matches TYPE_MATCHER

  • entity(ENTITY_MATCHER): the type is declared and the declaration matches ENTITY_MATCHER

  • exception(EXCEPT[||EXCEPT]*): the type has an exception-specifier that matches matches one of EXCEPT

  • floating(): the type is floating

  • incomplete(): the type is incomplete

  • inner(TYPE_MATCHER): the inner type matches TYPE_MATCHER

  • integral(): the type is integral

  • item(TYPE_MATCHER): after skipping any number of desugared array types, the non-array or pointer type of the innermost item matches TYPE_MATCHER TYPE_MATCHER

  • lib_builtin(LIB_BUILTIN): the type is the same as builtin LIB_BUILTIN

  • max_array(TYPE_MATCHER): an array type whose maximum level non-array type matches TYPE_MATCHER

  • max_pointer(TYPE_MATCHER): a pointer type whose maximum level pointee matches TYPE_MATCHER

  • misra_boolean(): the type is MISRA Boolean

  • node(ASTF[||ASTF]*): the type matches one of the AST functors

  • pointer(TYPE_MATCHER): the type is a pointer and its pointee type matches TYPE_MATCHER

  • promoted(BUILTIN_EXTENDED): the type is the promoted builtin BUILTIN_EXTENDED

  • qual(TYPE_QUALIFIER,TYPE_PTR_WHERE): the type at pointer depth TYPE_PTR_WHERE has a qualifier matching TYPE_QUALIFIER (Note: the presence of the _Atomic qualifier should be checked with the node(atomic) matcher)

  • record_decl(DECL_MATCHER): the type is a record whose declaration matches DECL_MATCHER

  • record_kind(RECORD_KIND): the type is a RECORD_KIND

  • ref_specifier(REF_SPECIFIER[||REF_SPECIFIER]*): the type is a function with ref-specifier one of REF_SPECIFIER

  • return(TYPE_MATCHER): the type is a function with return type matching TYPE_MATCHER

  • scalar(): the type is scalar

  • signed(): the type is signed

  • single_inheritance_hierarchy(): the type is a class with a single inheritance hierarchy

  • std(STDS_MATCHER): the standard used is STDS_MATCHER (see the -stds global configuration)

  • this_qual(TYPE_QUALIFIER): the type of this has a qualifier matching TYPE_QUALIFIER

  • unsigned(): the type is signed

  • variably_modified(): the type is a variably modified array

  • variadic(): the type is a variadic function

  • ID: the type matches the matcher associated to ID in -type_selector global configuration

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

REGEX

accepted forms are:

BUILTIN

accepted forms are:

  • _Bool: _Bool

  • __int128_t: __int128_t

  • __uint128_t: __uint128_t

  • bool: bool

  • char: char

  • char8_t: char8_t

  • char16_t: char16_t

  • char32_t: char32_t

  • double: double

  • float: float

  • half: half

  • int: int

  • long double: long double

  • long long: long long

  • long: long

  • short: short

  • signed char: signed char

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

  • void: void

  • wchar_t: wchar_t

  • nullptr_t: nullptr_t

  • short _Accum: short _Accum

  • _Accum: _Accum

  • long _Accum: long _Accum

  • unsigned short _Accum: unsigned short _Accum

  • unsigned _Accum: unsigned _Accum

  • unsigned long _Accum: unsigned long _Accum

  • short _Fract: short _Fract

  • _Fract: _Fract

  • long _Fract: long _Fract

  • unsigned short _Fract: unsigned short _Fract

  • unsigned _Fract: unsigned _Fract

  • unsigned long _Fract: unsigned long _Fract

  • _Sat short _Accum: _Sat short _Accum

  • _Sat _Accum: _Sat _Accum

  • _Sat long _Accum: _Sat long _Accum

  • _Sat unsigned short _Accum: _Sat unsigned short _Accum

  • _Sat unsigned _Accum: _Sat unsigned _Accum

  • _Sat unsigned long _Accum: _Sat unsigned long _Accum

  • _Sat short _Fract: _Sat short _Fract

  • _Sat _Fract: _Sat _Fract

  • _Sat long _Fract: _Sat long _Fract

  • _Sat unsigned short _Fract: _Sat unsigned short _Fract

  • _Sat unsigned _Fract: _Sat unsigned _Fract

  • _Sat unsigned long _Fract: _Sat unsigned long _Fract

  • UNSIZED_UNSIGNED_INTEGRAL: unsigned, unsized, integral built-in

  • UNSIZED_SIGNED_INTEGRAL: signed, unsized, integral built-in

  • FLOATING: floating point built-in

UNSIZED_UNSIGNED_INTEGRAL

accepted forms are:

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

UNSIZED_SIGNED_INTEGRAL

accepted forms are:

  • signed char: signed char

  • long long: long long

  • long: long

  • short: short

  • int: int

FLOATING

accepted forms are:

  • double: double

  • long double: long double

  • float: float

  • half: half

ENUM_MATCHER

accepted forms are:

  • any(): any enum type

  • name(NAME_MATCHER): the enum name matches NAME_MATCHER

  • type(TYPE_MATCHER): the type is an enum whose underlying integral type is a type matching TYPE_MATCHER

  • entity(ENTITY_MATCHER): the type is an enum and the corresponding entity matches ENTITY_MATCHER

LIB_BUILTIN

accepted forms are:

  • size_t: the underlying type of size_t

  • ssize_t: the underlying type of ssize_t

  • intmax_t: the underlying type of intmax_t

  • uintmax_t: the underlying type of uintmax_t

  • ptrdiff_t: the underlying type of ptrdiff_t

  • uptrdiff_t: the underlying type of uptrdiff_t

  • wchar_t: the underlying type of wchar_t

  • wint_t: the underlying type of wint_t

REF_SPECIFIER

accepted forms are:

  • rvalue: type is a function with ref-specifier &&

  • lvalue: type is a function with ref-specifier &

  • empty: type is a function with no ref-specifier

ARRAY_KIND

accepted forms are:

  • any: any array kind

  • incomplete: incomplete array

  • variable: variable array

  • constant: constant array

  • dependent: dependent array

TYPE_QUALIFIER

accepted forms are:

  • restrict: restrict qualifier

  • volatile: volatile qualifier

  • const: const qualifier

  • plain: no qualifier

ARRAY_SIZE_MOD

accepted forms are:

  • normal: normal

  • star: star

  • static: static

RECORD_KIND

accepted forms are:

  • class: class

  • struct: structure

  • union: union

TYPE_PTR_WHERE

accepted forms are:

  • top_level: the top level type

  • any_pointer_level: the top level type or a type at any pointee level

BIT_SIGNEDNESS

accepted forms are:

  • explicit_signed: the bitfield is explicitly signed

  • explicit_unsigned: the bitfield is explicitly unsigned

  • implementation_signed: it is implementation-defined whether the bitfield is signed

  • implementation_unsigned: it is implementation-defined whether the bitfield is unsigned

EXCEPT

accepted forms are:

  • nothrow: the nothrow exception specifier

  • throw_any: the nothrow_any exception specifier

  • unevaluated: the unevaluated exception specifier

  • uninstantiated: the uninstantiated exception specifier

  • unparsed: the unparsed exception specifier

  • throw: the throw exception specifier

  • noexcept: the noexcept exception specifier


Option -value_selector
-value_selector
-value_selector={ID, VALUE_MATCHER},...

Associates a selection identifier to an expression defining the matching report area values.

The configuration’s content is a collection of named selectors for report area values.

ID:

message value selection identifier.

VALUE_MATCHER:

an expression defining the matching values. Accepted forms are:

  • [+]AND_MATCHER: the value matches AND_MATCHER

  • -AND_MATCHER: the value does not match AND_MATCHER

  • [+]AND_MATCHER||VALUE_MATCHER: either the value matches AND_MATCHER or it matches VALUE_MATCHER

  • -AND_MATCHER||VALUE_MATCHER: the value does not match AND_MATCHER but does match VALUE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the value matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the value matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (VALUE_MATCHER): the value matches VALUE_MATCHER

  • !BASIC_MATCHER: the value does not match BASIC_MATCHER

  • any(): any value matches

  • none(): no value matches

  • ^REGEX$: the value matches ^REGEX$

  • fmt(REGEX): value’s format label matches REGEX

  • field(ID,VALUE_MATCHER): value whose field ID matches VALUE_MATCHER

  • item(MIN_MAX,VALUE_MATCHER): value where at least one item in MIN_MAX range matches VALUE_MATCHER

  • text(TEXT): value text

  • ID: the value matches the matcher associated to ID in -value_selector global configuration

REGEX

accepted forms are:


File classification

Option -public_files
-public_files
-public_files=FILE_MATCHERS,...

Specify the files that should be considered public API files.

FILE_MATCHERS,…:

set of file matchers. Accepted members are:

  • FILE_MATCHER: a -file_tag identifier or a matcher expression whose matching files are all considered as public API files.

Default:

-public_files="kind(system||extern_c_system)"

Option -std_files
-std_files
-std_files=FILE_MATCHERS,...

Specify the files that should be considered part of the standard library. If unset, files with kind system and extern_c_system are considered as being definitely part of standard library, while other files are considered as being possibly part of standard library.

FILE_MATCHERS,…:

set of file matchers. Accepted members are:

  • FILE_MATCHER: a -file_tag identifier or a matcher expression used to select the files.

Default:

-std_files={}

Declaration properties

Option -decl_properties
-decl_properties
-decl_properties={MATCHER, {PROPERTY,...}},...

Specify a declaration’s properties.

The configuration’s content is a list of declaration specifications with known properties.

MATCHER:

decl or macro matcher. Accepted forms are:

  • <MACRO_MATCHER: the input term is a macro that matches MACRO_MATCHER (see the -macro_selector global configuration)

  • DECL_MATCHER: the input term is declaration that matches DECL_MATCHER (see the -decl_selector global configuration)

PROPERTY:

declaration property. Accepted forms are:

  • unused: declaration is considered unused

  • used: declaration is considered used

  • fixed_signature: declaration is considered to have a fixed signature

  • alloc_id(ID): declaration has allocation identifier Id


Option -default_decl_properties
-default_decl_properties
-default_decl_properties=PROPERTY,...

Specify the default properties for declarations.

The configuration’s content is list of default properties.

PROPERTY:

declaration property. Accepted forms are:

  • unused: declaration is considered unused

  • used: declaration is considered used

  • fixed_signature: declaration is considered to have a fixed signature

  • alloc_id(ID): declaration has allocation identifier Id

Default:

-default_decl_properties={}

Option -extra_definitions
-extra_definitions
-extra_definitions=MATCHERS,...

Specifies undefined entities.

MATCHERS,…:

the matcher matches the entity. Accepted members are:

  • MATCHER: the entity matches MATCHER (see -entity_selector global configuration).

Default:

-extra_definitions="linkage(external)&&all_decl(forward_decl()&&loc(top(std())))"

Option -extra_references
-extra_references
-extra_references={FROM_MATCH, TO_MATCH},...

Specifies functions with the functions they call.

The configuration’s content is a set of pairs of FROM and TO entities; the FROM definition calls/refers to the TO entity.

FROM_MATCH:

the referee entity matches the entity matcher FROM_MATCH (see the -entity_selector global configuration). Use an empty string as matcher if the referred entities (the ones matching TO_MATCH) are entry points or interrupt handlers.

TO_MATCH:

the referred entity matches the entity matcher TO_MATCH (see the -entity_selector global configuration).

Default:

-extra_references={"", __main_function_entity},
  {"", "any_decl(property(used))"}

Option -function_error
-function_error
-function_error={ID, WHERE, FMT, {{VALUE_TAG, VALUES, FMT},...}},...

Specify function error conditions.

The configuration’s content is a collection of named error value conditions.

ID:

a unique identifier for this caller error specification.

WHERE:

either where the value is stored or indicate that it is the returned value. Accepted forms are:

  • return_value: the error value is the called function’s return value

  • errno: the error value is the value of errno

  • STMT_MATCHER: the error value is in an expression that matches STMT_MATCHER (see the -stmt_selector global configuration)

  • prepost(STMT_MATCHER0,STMT_MATCHER1): immediately before the call, a pre-action expression matches STMT_MATCHER0 and the error value is an expression that matches STMT_MATCHER1 (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template g_function_error__default_fmt) to specify the message describing WHERE.

VALUE_TAG:

the identifier for this value specification; the empty string indicates that the value is ok.

VALUES:

values that represent errors. Accepted forms are:

  • true: the Boolean value true

  • false: the Boolean value false

  • null: the null pointer

  • in(MIN_MAX): the error value is in MIN_MAX

  • not_in(MIN_MAX): the error value is not in MIN_MAX

  • return_type_cast(NUM): the type value is VALUE; if type is unsigned, then NUM is wrapped

  • STMT_MATCHER: the error value is evaluated by an expression that matches STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template g_function_error__default_fmt) to specify the message describing VALUE_TAG.


Call properties

Option -call_properties
-call_properties
-call_properties={CALL_MATCHER, {PROPERTY,...}},...

Specify a call expression’s properties.

The configuration’s content is a list of call specifications with known properties.

For each call_specification, each property should be specified at most once.

Example of usage:

-call_properties+={"name(fun)",{"pointee_write(1..3=maybe)",
                                "pointee_read(1=never&&2=maybe)"
                                "nothrow",
                                "taken(1..3=never)"}}

The above configuration informs ECLAIR that:

  • for all calls to functions named fun

    • the first 3 arguments may be written,

    • the first argument is never read,

    • the second argument may be read,

    • no exceptions are thrown and

    • the first 3 arguments are not taken

The properties const, fp_const, pure, noeffect, nothrow and any are called impact properties. There is a (transitive) relation implied for the impact properties given by:

const > fp_const > pure > noeffect > nothrow > any

where IMPACT1 > IMPACT2 signifies that IMPACT1 implies IMPACT2.

Note that if a property has impact pure (resp., const), it is assumed that the called function is pure or (resp., const) (see GCC official documentation)

Where supported by the standard, it is assumed that any properties assigned to a function using the attribute specifier always hold. For example, with the declaration:

void f() __attribute__((pure));

it is assumed that the impact pure holds for all calls to function f()

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.

PROPERTY:

call property. Accepted forms are:

  • const_pointee_read(POINTEE_RW[&&POINTEE_RW]*): indicate the read use for call arguments that correspond to parameters whose pointee types are const

  • const_pointee_write(POINTEE_RW[&&POINTEE_RW]*): indicate the write use for call arguments that correspond to parameters whose pointee types are const

  • data_kind(POS_MIN_MAX,TKIND): the call arguments or return in the specified index range POS_MIN_MAX have the specified data kind. Index 0 refers the return value, the indices of the arguments start from 1

  • errno[(MODE)]: if the argument is omitted or MODE is true, then, when an error occurs, the errno indicator will be set. If MODE is false, then the errno indicator is not set

  • error(ID[&&ID]*): function error is specified by ID

  • ignorable_result[(MODE)]: if the argument is omitted or MODE is true, then the call is considered as having an ignorable result. If MODE is false, then the call is considered as having a non-ignorable result

  • IMPACT: the call has impact IMPACT

  • impact(IMPACT): the call has impact IMPACT

  • malloc[(MODE)]: if the argument is omitted or MODE is true, then the call is considered as having the malloc property. If MODE is false, then the call is considered as not having the malloc property

  • math_err[(MODE)]: if the argument is omitted or MODE is true, then the call is considered as possibly setting the errno indicator and/or raising a floating-point exception if an error occurs according to the value of math_errhandling. If MODE is false, then the call is considered as not setting the errno indicator and/or raising a floating-point exception. non-const

  • noeffect: like pure but can also read volatile variable not triggering side effects. This is equivalent to impact(noeffect)

  • noreturn[(MODE)]: if the argument is omitted or MODE is true, then the call is considered to be non-returning. If MODE is false, then the call is considered to be returning

  • pointee_read(POINTEE_RW[&&POINTEE_RW]*): indicate the read use for call arguments that correspond to parameters whose pointee types are non-const

  • pointee_write(POINTEE_RW[&&POINTEE_RW]*): indicate the write use for call arguments that correspond to parameters whose pointee types are non-const

  • points_to(POINTS_TO_ITEM[&&POINTS_TO_ITEM]*): all the points_to properties must hold

  • resource(RESOURCE_ITEM[,RESOURCE_ITEM]*): indicates a set of property resources that must hold

  • returned([RETURNED[&&RETURNED]*]): indicates that the specified address arguments may be returned; address arguments not listed are never returned

  • tag(Id[&&Id]*): user-defined property tags

  • taken([TAKEN[&&TAKEN]*]): indicates that the specified address arguments may be stored in objects that persist after the function has ceased to exist (excluding the returned value); address arguments not listed are never taken

POINTEE_ARG

accepted forms are:

  • POS_MIN_MAX: argument index for callee. Index 0 refers to the return value, the indices of the arguments start from 1

  • this: this argument for callee

PRE_POST

accepted forms are:

  • pre: the property holds before the call

  • post: the property holds after the call

POINTEE_LEVEL

accepted forms are:

  • *[*]*: the dereference level is shown by the number of *‘s (the default level is 1)

POINTEE

accepted forms are:

  • POS_NUM: the pointee at index POS_NUM, the indices of the arguments start from 1

  • this: this argument

POINTEE_LHS

accepted forms are:

  • static: points to static lifetime objects

  • any: points to any object

  • POINTEE_LEVELPOINTEE: the PTEE pointee and dereference level POINTEE_LEVEL

POINTEE_RHS

accepted forms are:

  • new: a pointer to a new unaliased object

  • none: not a pointer

  • null: points to null

  • static: points to static lifetime objects

  • PRE_POST(POINTEE_LEVELPOINTEE): the PTEE pointee and dereference level POINTEE_LEVEL PRE_POST

  • POINTEE_LEVELPOINTEE: the PTEE pointee and dereference level POINTEE_LEVEL PRE_POST

PRE_POST_LHS

accepted forms are:

  • POINTEE_LHS[||POINTEE_LHS]*: one of the pointees must match

  • !POINTEE_LHS[&&POINTEE_LHS]*: none of the specified pointees match

PRE_POST_RHS

accepted forms are:

  • POINTEE_RHS[||POINTEE_RHS]*: one of the pointees must match

  • !POINTEE_RHS[&&POINTEE_RHS]*: none of the specified pointees match

POINTS_TO_ITEM

accepted forms are:

  • PRE_POST(PRE_POST_LHS=PRE_POST_RHS): the pointees specified by PRE_POST_LHS has a PRE_POST relation with the pointees specified by PRE_POST_RHS. The indices start from 1

RESOURCE_ITEM

accepted forms are:

  • RESOURCE_WHERE=ID:RESOURCE_STATES0>RESOURCE_STATES1: the resource RESOURCE_WHERE with identifier ID has input state RESOURCE_STATES0 and output state RESOURCE_STATES1

RW

accepted forms are:

  • always: for pointee_read: argument pointee is expected to be fully initialized at function enter and, for pointee_write: argument pointee is fully initialized at function exit

  • maybe: for pointee_read: argument pointee may be expected to be initialized at function enter and, for pointee_write: argument pointee may be written by function body

  • never: for pointee_read: argument pointee is not expected to be initialized at function enter and, for pointee_write: argument pointee is never written by function body

POINTEE_RW

accepted forms are:

  • POINTEE_ARG=RW: the known read or write use of each argument pointee passed by reference or pointer with index in range POS_MIN_MAX or this. The indices start from 1

RESOURCE_WHERE

accepted forms are:

  • POS_NUM: if POS_NUM = 0, then the return value otherwise the argument index; the argument indices start from 1

  • ENTITY_MATCHER: an entity matching ENTITY_MATCHER (see the -entity_selector global configuration)

RESOURCE_STATES

accepted forms are:

  • ID[||ID]*: set of resource states

BOOL3

accepted forms are:

  • always: the action happens always before the function returns

  • maybe: the action might happen or not happen before the function returns

  • never: the action never happens before the function returns

MODE

accepted forms are:

  • true: the property is true

  • false: the property is false

IMPACT

accepted forms are:

  • const: call is const. That is, it is assumed that the called function is const

  • fp_const: the floating-point environment is unchanged and the call is const

  • pure: call is pure. That is, it is assumed that the called function is pure

  • noeffect: a call to a function with no external side effect. That is, it is assumed that: there are no indirect calls; any throw is caught within the function; there are no calls to new, delete, a non-trivial constructor or a destructor; it does not write to a variable that is volatile or has static storage; and it does not read from a volatile variable that triggers a side effects

  • nothrow: a call to a function for which it is assumed that any thrown exceptions are caught within the function

  • any: the call can have any impact

RETURNED

accepted forms are:

  • POINTEE_ARG=BOOL3: the arguments passed by reference or pointer with indices included in POINTEE_ARG may be returned. The indices start from 1

TAKEN

accepted forms are:

  • POINTEE_ARG=BOOL3: the arguments passed by reference or pointer with indices included in POINTEE_ARG may be taken. The indices start from 1

TKIND

accepted forms are:

  • bool: the argument is effectively boolean

  • int_bool: the argument is a boolean represented as an integer

  • int_byte: the argument is a byte represented as an integer

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option -default_call_properties
-default_call_properties
-default_call_properties=PROP,...

Specify the default properties for call expressions. Default properties of functions listed in the -extra_definitions global configuration (whose body is not visible to ECLAIR) are not taken into account, since they cannot be verified.

The configuration’s content is a set of properties.

PROP:

call property.

Default:

-default_call_properties="const_pointee_read(1..=maybe&&this=maybe)",
  "pointee_read(1..=maybe&&this=maybe)",
  "const_pointee_write(1..=never&&this=never)",
  "pointee_write(1..=maybe&&this=maybe)"

Option -variadic_fmt
-variadic_fmt
-variadic_fmt={ID, CALL_MATCHER, {{REGEX, {{REGEX, MATCHER},...}},...}},...

Specify nonstandard format specifiers for calls to variadic functions.

The configuration’s content is list of identifiers with call matchers, format specifiers and matchers for the corresponding arguments.

ID:

identifier.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.

REGEX:

regex to match the conversion specification from a formatting string and where the capturing groups are for texts to be matched by the argument specifiers.

REGEX:

regex matching a conversion specifier.

MATCHER:

a -stmt_selector identifier or a matcher expression used to select the arguments.

Default:

-variadic_fmt={std_print, "name(printf||fprintf||sprintf||snprintf||wprintf||fwprintf||swprintf)", {{^.*$, {}}}}, {std_scan, "name(scanf||fscanf||sscanf||wscanf||fwscanf||swscanf)", {{^.*$, {}}}}

Requirements tracking

Option -requirement_coverages
-requirement_coverages
-requirement_coverages={ID, COVERAGE_TAG, {Flags,...}},...

Specify requirement_coverages.

The configuration’s content is a collection of coverage identifiers paired with a set of requirement tags and a set of flags. The coverage identifiers are used in the declaration of requirements sets (see the -requirements global configuration content).

ID:

coverage identifier.

COVERAGE_TAG:

coverage Doxygen tag to be matched.

Flags,…:

flags. Accepted members are:

  • FLAG: flag. Accepted forms are:

  • single: the coverage comment shall refer to a single requirement

Default:

-requirement_coverages={}

Option -requirements
-requirements
-requirements={SET_ID, {REQ_TAGS,...}, {COV_IDS,...}},...

Specify requirements sets.

The configuration’s content is a collection of requirement identifiers paired with a set of requirement tags.

SET_ID:

set identifier.

REQ_TAGS,…:

requirement tags. Accepted members are:

  • REQ_TAG: requirement tag.

COV_IDS,…:

coverage identifiers. Accepted members are:

  • COV_IDS: coverage identifier.

Default:

-requirements={}

Standard libraries

Option -stdlib_description
-stdlib_description
-stdlib_description={LIB, LANG, YEAR, STD, BRIEF, FULL},...

Specifies descriptions for libraries included in source code.

The configuration’s content is library descriptions.

LIB:

used library.

LANG:

language.

YEAR:

year.

STD:

the library is based on a standard that matches STD (see the -stds global configuration).

BRIEF:

brief description.

FULL:

full description.

Default:

-stdlib_description={posix, c, 1990, c90_, POSIX, "Portable Operating System Interface (POSIX.1-2008)"}

Option -stdlib_reserved
-stdlib_reserved
-stdlib_reserved={LIB, HEADER, NAME_MATCHER, ID_CLASSES, RESERVE},...

Specifies identifiers reserved by non-standard libraries that are included in source code.

The configuration’s content is library reserved identifers.

LIB:

library defined by a -stdlib.

HEADER:

regular expression or verbatim text to select the header names.

NAME_MATCHER:

a -name_selector name or a matcher expression for the identifiers, optionally preceded by a qualifier and ‘:’.

ID_CLASSES:

identifier classes. Accepted forms are:

  • any: any entity class or macro (this excludes any keyword or common_extension)

  • code: any entity class

  • keyword: any keyword

  • common_extension: any common extension

  • function(ARITY): a function with arity ARITY

  • function_like(ARITY): a function or function-like macro with arity ARITY

  • fun_macro(ARITY): a function-like macro with arity ARITY

  • ID_CLASS[||ID_CLASS]*: the identifier class is one of ID_CLASS

ID_CLASS

accepted forms are:

  • class: class name

  • enum: an enumerator name

  • enum_constant: enum_constant name

  • function: function name

  • fun_macro: function-like macro name

  • member: field name

  • namespace: namespace name

  • operator: operator name

  • pragma: pragma name

  • struct: struct name

  • union: union name

  • typedef: typedef name

  • variable: variable name

RESERVE:

when the identifier is reserved. Accepted forms are:

  • always: always reserved

  • never: never reserved

  • define: reserved except for macro #define and #undef

  • std_global: reserved in namespace std and in the global namespace

  • namespace_decl: reserved for namespace identifiers

  • decl(DECL_MATCHER[,STRING]): is reserved for identifiers with a declarations that match DECL_MATCHER (see the -decl_selector global configuration); an optional brief description for the report messages is given by STRING

  • C_CONDS[&&C_COND]*: reserved in the C language for an identifier satisfying all of C_COND

C_COND

accepted forms are:

  • file_scope: the identifier has file scope

  • external_linkage: the identifier has external linkage

  • name_space(NAME_SPACE[||NAME_SPACE]*): reserved for an identifier in one of the name spaces NAME_SPACE

NAME_SPACE

accepted forms are:

  • label: name space label

  • member: name space member

  • ordinary: name space ordinary

  • tag: name space tag


Option -stdlib
-stdlib
-stdlib=LIBRARIES,...

Specifies standard libraries included in source code.

LIBRARIES,…:

libraries used. Accepted members are:

  • LIB: used library.

Default:

-stdlib={}

Others

Option -multibyte_character_prefixes
-multibyte_character_prefixes
-multibyte_character_prefixes={MIN, MAX},...

Specifies allowed characters.

The configuration’s content is a set of ranges of allowed character codes.

MIN:

minimum. It must be an integer greater than or equal to 0.

MAX:

maximum. It must be an integer less than or equal to 0.

Default:

-multibyte_character_prefixes={127, 255}

Option -reference_std
-reference_std
-reference_std={TAG, STD_SPEC},...

Specify the reference standard referred to by TAG.

The configuration’s content is a collection of named reference language standards.

TAG:

selection tag.

STD_SPEC:

standard expression. Accepted forms are:

  • max(STD): the oldest standard between STD and the unit standard

  • min(STD): the newest standard between STD and the unit standard

  • std(STD): the reference standard is STD

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-reference_std={STD, "std()"}

Intercepting the Toolchain

One of the main strengths of ECLAIR is that it intercepts every invocation of the toolchain components (compilers, linker, assembler, librarian or archive manager) and it automatically extracts and interprets the options that the build system has passed to them. This allows for the seamless integration with any build system, whether it is makefile-based, script-based or a hybrid.

Automatic Toolchain Identification

By default, ECLAIR automatically identifies and intercepts all the toolchain components invoked by the build procedure without requiring any configuration from the user.

Manual Tool Identification

On the other hand, the high configurability of ECLAIR also allows the user to override the default and explicitly identify the toolchain components to be intercepted.

Each component of a toolchain is identified by the tool’s front end program; that is, the program that is directly invoked by the build procedure. The fact that the front end might, in turn, invoke other programs does not matter if these are not invoked directly by the build procedure. A tool can be specified in two ways: by its name or by its full path.

PATH-Based Tool Specification by Name

The front end program of a tool can be specified by name only when there is no doubt that the build procedure will invoke the correct instance of the named program, that is, the selected program will be the one contained in the first directory in PATH that contains an executable program with that name.

It must be stressed that this method of tool specification can only be used when the build procedure invokes the tool using the standard PATH-based mechanism. In case of doubt, specification by full path should be used.

Tool Specification by Full Path

The front end program of a tool can also be specified by providing its full (absolute) path or a regular expression that matches the full path.

Tool Specification Variables

Use environment variables to tell ECLAIR which tools should be intercepted. These are:

CC_ALIASES

for the C compiler;

CXX_ALIASES

for the C++ compiler;

AS_ALIASES

for the assembler;

AR_ALIASES

for the librarian;

LD_ALIASES

for the linker;

FILEMANIP_ALIASES

for file copiers and movers such as cp, objcopy and mv.

Such environment variables take multiple specifications (by name or by full path) separated by blank space. For example, with a Windows command-line interpreter, one could use

set CC_ALIASES=cc gcc-4.8.1 ^.*clang.*$

to tell ECLAIR to intercept PATH-based invocations of cc, gcc, and gcc-4.8.1 and intercept invocations of C compilers whose full path contains the string clang. Note that there is no need to add an executable extension to the program names because ECLAIR will use the same algorithm used by the command interpreter. Hence, in response to command cc, a program called cc.exe or cc.bat would be executed (i.e., ECLAIR will do the right thing). Of course, if you want to restrict interception to .exe files, you can use

set CC_ALIASES=cc.exe gcc.exe gcc-4.8.1.exe ^.*clang.*\.exe$

With a Bourne shell derivative one would obtain the same effect by setting the CC_ALIASES environment variable as follows:

export CC_ALIASES="cc gcc gcc-4.8.1 ^.*clang.*$"

Note that, if one or more the tool specifications contain blank spaces, quoting is necessary. For an example on Windows consider

set LD_ALIASES="path with space/lnk1" lnk2 lnk3

whereas with a Bourne shell derivative we would use

export LD_ALIASES="'path with space/lnk1' lnk2 lnk3"

Tool Exclusion Variables

Environment variables can be used also to tell ECLAIR which tools should not be intercepted. These are:

CC_NALIASES

for the C compiler;

CXX_NALIASES

for the C++ compiler;

AS_NALIASES

for the assembler;

AR_NALIASES

for the librarian;

LD_NALIASES

for the linker;

FILEMANIP_NALIASES

for file copiers and movers such as cp, objcopy and mv.

Such environment variables take multiple specifications by full paths separated by blank space.

For example, with a Bourne shell derivative, one would use

export CC_NALIASES="^.*(gcc-4\.8\.1|clang).*$"

to tell ECLAIR not to intercept invocations of C compilers whose full path contains the string gcc-4.8.1 or clang.

Note that the tool exclusion variables (*_NALIASES) take precedence over the tool selection variables (*_ALIASES).

Services

This section contains generic documentation that applies to all services integrated in the ECLAIR instance this manual refers to. A templates for the configuration of service SERVICE is provided in

PREFIX/eclair-VERSION/share/config/templates/SERVICE.ecl

In the following sections we present the services supported by this release of ECLAIR and the means to configure their behaviour.

The descriptions of the services include

  • a short summary of the service: most often this is the headline under which the service is presented in the corresponding coding standard;

  • a detailed description of the service: this contains a best-effort interpretation of the service’s letter and spirit, taking into account all the available, authoritative sources of information;

  • information about the implementation: a best-effort description of what the checker actually checks (only for services where the ECLAIR checker is not exact with respect to the description);

  • information on the configuration: several services and all checkers are configurable to some extent and this part explains everything.

File portions and sources

The description section of each service clarifies, among other things, which portions of the project files and the supporting files are checked. The following terminology is used:

project file contents

This is the contents of all the files that belong to the project being checked, typically all files in the directory trees rooted into a specified set of root project directories. Note that not all these files will contain code and even those containing code might not be opened by the compiler due to the particular project configuration in force or because the build procedure decided not to (re)compile them.

external source file contents

This is the contents of all the source files that are opened by the compiler during the build process and are not project files. This includes the system header files, non-system library header files, source files of libraries that are not part of the project.

compiled file contents

This is the contents of all the source files that are opened by the compiler during the build process. This may include both project source files and external source files.

non-skipped compiled file contents

This consists of the portions of the compiled files that have not been excluded by conditional compilation directives, such as #if, #ifdef, #ifndef.

preprocessed source

This consists of all the source code output by the preprocessor during the build, which does not include comments, does not include portions excluded by conditional compilation directives, and contains the final result of macro expansion.

non-pattern source

This is the portion of the preprocessed source that does not contain the (uninstantiated) C++ templates.

pattern source

This is the portion of the preprocessed source consisting of all (uninstantiated) C++ templates.

template instances

This is the code resulting from the full instantiation of the pattern preprocessed code. Note that this code, which is the outcome of an intermediate phase of the compilation process, is not part of the preprocessed source. In other words, template instances are not (explicitly) written in the code; they are synthesized by the compiler.

object source

This is the union of the non-pattern source and template instances.

The following examples should clarify the above concepts and terminology:

 1/*
 2
 3  `project files contents':
 4    <PROJECT_ROOT>/README.txt
 5    <PROJECT_ROOT>/non_compiled.c
 6    <PROJECT_ROOT>/include/never_included.h
 7    <PROJECT_ROOT>/test.cc
 8
 9  `compiled files contents':
10    <PROJECT_ROOT>/test.cc
11    /usr/include/stdio.h
12
13  `external source files contents':
14    /usr/include/stdio.h
15
16*/
17
18/* This comment and the lines below down to #if 0 are part of
19   `non-skipped compiled file contents'.  */
20/* The preprocessed contents of /usr/include/stdio.h is part of
21   `preprocessed source'.  */
22#include <stdio.h>
23
24/* The tokens in the line after next comment are part of `preprocessed
25   source' and `non-pattern source'.  */
26double our_var;
27
28#define our_macro(x) x + 1
29
30#if 0
31/* This comment and the two lines below are *not* part of
32   `non-skipped compiled file contents'.  */
33int their_var;
34#define their_macro(x) x + 2
35#endif
36
37/* The following contents is part of `non-skipped compiled file
38   contents'.  */
39/* Macros and comments are *not* part of `preprocessed source' */
40/* The following contents (comments apart) is part of `preprocessed
41   source'.  */
42
43/* The following function declaration source is part of `non-pattern
44   source'.  */
45void f();
46
47/* The following function template source is part of `pattern
48   source'.  */
49template <typename T>
50T id(T x) {
51  return x;
52}
53
54/* The following function definition source is part of `non-pattern
55   source'.  */
56int g(int x) {
57  /* The content of the instance of function template `id'
58     instantiated with T = int by the following statement is part of
59     `template instances'.  */
60  printf("%d\n", id(x));
61}

Redundant code classification

Several services require checking for and, where necessary, reporting on specific forms of redundant code. The description and implementation sections for these services use the following terminology to indicate more precisely the exact form of redundant code being referred to:

unreachable

The code is not evaluated because, for purely syntactical or type analysis reasons (i.e., independent from the result of previous evaluations), it can not be reached by control flow; for instance:

return; unreachable();

Note that code that is unreachable following this definition will be unreachable according to the descriptions in MISRA C:2012 (see pages 40, 41 and 225, 226 ) of [45]. However unfeasible code as specified below, is also MISRA C:2012 unreachable.

unfeasible

The code is reachable, but not evaluated because no actual control flow that leads to it can be followed. As unfeasibility will depend on the precise values of variables used in the guards, any compile-time analysis for proving unfeasibility will be imprecise, the degree of the precision depending on the analysis technique:

  • constant: compile time constant guards are taken in account. Hence the call to unreachable() in the example below has constant unfeasibility; for example:

    if (0) unreachable();
    
  • type-range: the type ranges of variables in the guards are taken into account; for example:

    unsigned int u;
    ...
    if (u < 0) unreachable();
    
  • value-intervals: guards value intervals are taken into account; for example:

    unsigned char uc;
    ...
    if (uc + 1 < 1000) unreachable();
    
  • live-variable: live variable analysis results are taken into account; for example:

    unsigned u;
    u = 3;
    if (u == 0) unreachable();
    
  • trivial-filter: the conjunction of tests in the guards is taken into account; for example:

    int i;
    ...
    if (i > 0 && i < 0) unreachable();
    if (i > 0 && b) {
      if (i < 0) unreachable();
    }
    
  • linear-constraints: linear constraints on the values of variables in the guards are taken into account; for example:

    int i, j;
    ...
    if (i + j > 2 && i < 2 && j < 2) unreachable();
    
  • linear-congruences: linear congruence relations on the values of variables in the guards are taken into account; for example:

    unsigned u;
    ...
    u = 2 * u;
    if (u % 2) unreachable();
    

Note that unfeasible code as defined here will be unreachable according to the description in MISRA C:2012 (see page 40 of [45] ).

effectless

The code is not unfeasible, but its evaluation is redundant because it has no side effects at all; for instance:

3 + 5 * 18;
dead-effects

The code is not effectless, but its effects do not change the program semantics; for instance:

unsigned u;
...
u = 2; // dead-effects
u = 3;

Note that effectless or dead-effects code as defined here will be dead code according to the description in MISRA C:2012 (see page 41 of [45] ).

Configuring a service

Each service can be configured to fine-tune its behaviour according to each project’s needs. To specify such service-dependent configurations, use the option described below.

Option -config

-config

-config=TAG,OPTION=VALUE,...

where TAG is an identifier denoting a single service or a set of services to which the option applies and

OPTION=VALUE,...: a set of options with associated values.

Each OPTION must be either a generic service option or service-specific option. and VALUE a valid value for this option. In some cases, the =VALUE can be omitted and the default value true is used. For example, to enable (respectively disable) the services defined by the tag, use just the OPTION enabled (respectively, disabled).

Generic Service Options

The configuration section of the presentation of each service includes descriptions of several service-specific configure options that will enable the reports that are output to be fine-tuned to suit the project.

There are also some general configuration options that allow for service dependent control of the service checking and reporting. Other global service-indipended configuration options are documented in the section Global Options.

Option enabled
enabled
-config=SERVICE,enabled=BOOL

Enable the service (see also the global configuration -enable for a shorter way to enable services).

BOOL:

the service state. Accepted values are:

  • false: the service is disabled;

  • true: the service is enabled;


Option disabled
disabled
-config=SERVICE,disabled=BOOL

Disable the service (see also the global configuration -disable for a shorter way to disable services).

BOOL:

the service state. Accepted values are:

  • false: the service is enabled;

  • true: the service is disabled;


Option summary
summary
-config=SERVICE,summary=SUMMARY

Summary for the service.

SUMMARY:

a string to be used as summary for the service.


Option strictness
strictness
-config=SERVICE,strictness=STRICTNESS

Service strictness.

STRICTNESS:

the strictness of this service.


Option tag
tag
-config=SERVICE,tag=TAG,...

List of tags associated to a specific service alias.

The configuration’s content is a list of tags associated to service.

TAG:

the tag for the service.


Option ntag
ntag
-config=SERVICE,ntag=TAG,...

List of tags associated to service without defining a preferred alias.

The configuration’s content is a list of tags associated to service.

TAG:

the tag for the service.


Option untag
untag
-config=SERVICE,untag=TAG,...

List of tags to be disassociated from the service.

The configuration’s content is user tags.

TAG:

the tag for the service.


Option reports
reports
-config=SERVICE,reports={TAGS, REPORT_MATCHER},...

Specifies the reports to hide.

The configuration’s content is a list of clauses specifying the reports and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option frames
frames
-config=SERVICE,frames={TAG, FRAME_MATCHER},...

Specify the interesting analysis frames using a short-circuit sequence.

The configuration’s content is a short-circuit sequence specifying the frames that should not be analyzed.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

FRAME_MATCHER:

a -frame_selector identifier or a matcher expression used to select the frames.


Option fmt
fmt
-config=SERVICE,fmt={FMT, TPL_FMT, CONTENT},...

Specify the format for the reports.

The configuration’s content is a collection of named message formats.

FMT:

format identifier.

TPL_FMT:

template identifier.

CONTENT:

format content string. Accepted forms are:

  • PARTPARTS: non empty parts

  • : empty parts

PART

accepted forms are:

  • %{EXPR}: result of EXPR

  • TEXT: text TEXT

EXPR

accepted forms are:

  • 'TEXT': text TEXT

  • n(PARAM): value of parameter PARAM

  • q(PARAM): quoted value of parameter PARAM

  • seq(EXPR,SEP): value of items in list EXPR separated by SEP

  • cond(EXPR_COND,EXPR_DEFAULT,CASES): value of EXPR_COND is tested against CASES, if nothing matches EXPR_DEFAULT is used

  • FMT(OPT_ARGS): fmt FMT is called

  • FMT(EXPROPT_COMMA_SEPOPT_COMMA_ARGS): fmt FMT is called on EXPR

  • ifmt(EXPR_FMT,IDOPT_COMMA_ARGS): fmt specified by EXPR_FMT (whose template is ID) is called

  • ifmte(EXPR_FMT,EXPR_VALUEOPT_COMMA_ARGS): fmt specified by EXPR_FMT is called on EXPR_VALUE

  • ifmts(EXPR_FMT,EXPR_SEQ,EXPR_SEPOPT_COMMA_ARGS): fmt specified by EXPR_FMT is called on sequence EXPR_SEQ using separator EXPR_SEP

OPT_ARGS

accepted forms are:

  • ID:EXPROPT_COMMA_ARGS: optional comma separated EXPR sequence

  • : no more expressions

OPT_COMMA_ARGS

accepted forms are:

  • ,OPT_ARGS: optional comma separated OPT_ARGS sequence

  • : no more args

OPT_COMMA_SEP

accepted forms are:

  • ,EXPR: comma followed by EXPR

  • : no more expressions


The BUGSENG Application Hazard Scanner Services

This section contains documentation on the Application Hazard Scanner services. These have been provided by BUGSENG to report code that is vulnerable to bugs in a build tool such as the compiler or linker.

Each of the service names is formed from the tool name and the bug’s reference tag. Thus, GCC.89698 checks for code vulnerable to the GCC bug 89698.

Rule AHS.GCC.63944

Summary

Code is vulnerable to GCC bug 63944. (See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63944 .)

Description

Partial overriding of non-constant struct/union initializers is shown.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=AHS.GCC.63944,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule AHS.GCC.89698

Summary

Code is vulnerable to GCC bug 89698. (See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89698 .)

Description

All conversions from void* to a class type that inherits from another class are reported as cautions.

Configuration

See generic service options.

Option casts
casts
-config=AHS.GCC.89698,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


The BUGSENG ECLAIR Services

This section contains documentation on ECLAIR services that were designed by BUGSENG in a completely independent way, that is, with no reference to existing coding standards or previous designs.

Debug B.CONST_DEBUG

Summary

Service for testing servant const.

Configuration

See generic service options.

Option declarations
declarations
-config=B.CONST_DEBUG,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Debug B.DECLFIND

Summary

Service for checking the decl matcher.

Description

Pseudo checker for checking decl matchers.

Configuration

See generic service options.

Option declarations
declarations
-config=B.DECLFIND,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Debug B.DECLFIND_PROG

Summary

Service for checking the decl matcher at link time.

Description

Pseudo checker for checking decl matchers at link time.

Configuration

See generic service options.

Option declarations
declarations
-config=B.DECLFIND_PROG,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Debug B.ENTTNAME_DEBUG

Summary

Pseudo-checker for enttname servant.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=B.ENTTNAME_DEBUG,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=B.ENTTNAME_DEBUG,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=B.ENTTNAME_DEBUG,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=B.ENTTNAME_DEBUG,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=B.ENTTNAME_DEBUG,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=B.ENTTNAME_DEBUG,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=B.ENTTNAME_DEBUG,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Debug B.EXPR_EVALUATOR_DEBUG

Summary

Pseudo-checker for expr_evaluator.

Configuration

See generic service options.

Debug B.FQNAME_DEBUG

Summary

Pseudo-checker for fqname.

Configuration

See generic service options.

Debug B.POINTS_TO_DEBUG

Summary

Service for testing servant points_to.

Configuration

See generic service options.

Debug B.PTO_DEBUG

Summary

Pseudo-checker for debugging the points-to analyzer.

Configuration

See generic service options.

Debug B.STMTFIND

Summary

Service for checking the stmt matcher.

Description

Pseudo checker for checking stmt selectors.

Configuration

See generic service options.

Option statements
statements
-config=B.STMTFIND,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=B.STMTFIND,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Debug B.TAKEN_DEBUG

Summary

Pseudo-checker for taken servant.

Configuration

See generic service options.

Debug B.XREF_DEBUG

Summary

Pseudo-checker for xref and xref_nodes servants.

Configuration

See generic service options.

The BUGSENG Meters

This section contains documentation for ECLAIR services for metric reporting of any selected metrics.

Meter B.METER

Summary

Supports the selection and reporting of source code metrics.

Description

Reports the source code metrics.

Note that the metric_show service configuration must be used to specify the metrics to be reported.

Configuration

See generic service options.

Option metric_default_fmt
metric_default_fmt
-config=B.METER,metric_default_fmt=FMT

Specify the default format.

FMT:

the default format (see the -fmt global configuration content, template reprtmtc__id_default_fmt) that should be used if no other format is specified; it has fields:

subject_kind

subject kind;

subject_msg

subject message;

subject_name

subject name;

subject_named

Boolean indicating if the subject has a name;

metric_id

metric identifier;

metric_summary

metric summary;

lower_case_metric_summary

metric summary in lowercase;

context_kind

context kind;

context_name

context name;

context_desc

context description;

report_where

a tag with values incremental or final indicating where the metric is reported;

domain

the environment or entity where the metric is reported;

domain_msg

a message describing the environment or entity where the metric is reported;

limit

the metric limit;

rel

the relation used to compare the limit with the metric value;

good_limit

the metric limit that must not be exceeded;

subject_eq_context

Boolean indicating if the context and subject are the same;

value

the actual value for the metric.

Default:

-config=B.METER,metric_default_fmt="%{__nolimit_fmt()}"

Option metric_fmt
metric_fmt
-config=B.METER,metric_fmt={METRIC, FMT},...

Specify metric message format.

METRIC:

name of a supported metric.

FMT:

format (see the -fmt global configuration content, template reprtmtc__id_default_fmt) with fields:

subject_kind

subject kind;

subject_msg

subject message;

subject_name

subject name;

subject_named

Boolean indicating if the subject has a name;

metric_id

metric identifier;

metric_summary

metric summary;

lower_case_metric_summary

metric summary in lowercase;

context_kind

context kind;

context_name

context name;

context_desc

context description;

report_where

is incremental or final indicating where the metric is reported;

domain

the environment or entity where the metric is reported;

domain_msg

a message describing the environment or entity where the metric is reported;

limit

the metric limit;

rel

the relation used to compare the limit with the metric value;

good_limit

the metric limit that must not be exceeded;

subject_eq_context

indicates if the context and subject are the same;

raw_value

the actual value for the metric;

value

the formatted value for the metric.

Default:

-config=B.METER,metric_fmt={}

Option metric_show
metric_show
-config=B.METER,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=B.METER,metric_show={}

Option metric_decimal_digits
metric_decimal_digits
-config=B.METER,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=B.METER,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter B.THRESHOLD

Summary

Supports the selection and reporting of source code metrics as violations.

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_fmt
metric_fmt
-config=B.THRESHOLD,metric_fmt={METRIC, FMT},...

Specify metric message format.

METRIC:

name of a supported metric.

FMT:

format (see the -fmt global configuration content, template reprtmtc__id_default_fmt) with fields:

subject_kind

subject kind;

subject_msg

subject message;

subject_name

subject name;

subject_named

Boolean indicating if the subject has a name;

metric_id

metric identifier;

metric_summary

metric summary;

lower_case_metric_summary

metric summary in lowercase;

context_kind

context kind;

context_name

context name;

context_desc

context description;

report_where

is incremental or final indicating where the metric is reported;

domain

the environment or entity where the metric is reported;

domain_msg

a message describing the environment or entity where the metric is reported;

limit

the metric limit;

rel

the relation used to compare the limit with the metric value;

good_limit

the metric limit that must not be exceeded;

subject_eq_context

indicates if the context and subject are the same;

raw_value

the actual value for the metric;

value

the formatted value for the metric.

Default:

-config=B.THRESHOLD,metric_fmt={}

Option metric_show
metric_show
-config=B.THRESHOLD,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=B.THRESHOLD,metric_show={}

Option metric_decimal_digits
metric_decimal_digits
-config=B.THRESHOLD,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=B.THRESHOLD,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


The ECLAIR C/C++ Parser

Parser B.PARSER

Summary

The code shall be parsable without errors by the ECLAIR parser. If the code is parsed with errors the AST is incomplete and the results of ECLAIR analyses are likely to be incorrect.

Description

Reports any errors found when parsing the source code.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=B.PARSER,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


The BUGSENG Report Services

Reporter B.REPORT.ECB

Summary

Output reports in ECB format.

Configuration

See generic service options.

Option output
output
-config=B.REPORT.ECB,output=OUTPUT_FILE

Specify the output destinations of the reports.

OUTPUT_FILE:

the output file name. The pattern @FRAME@ is replaced with current analysis frame number.

Default:

-config=B.REPORT.ECB,output=/tmp/FRAMES.ecb

Option includes
includes
-config=B.REPORT.ECB,includes=LEVELS

Specify if the #include chains should be in the report.

LEVELS:

the number of #include chain levels to be shown.

Default:

-config=B.REPORT.ECB,includes=0

Option macros
macros
-config=B.REPORT.ECB,macros=LEVELS

Specify if the expansion chains should be output.

LEVELS:

the number of expansion chain levels to be shown.

Default:

-config=B.REPORT.ECB,macros=0

Option preprocessed
preprocessed
-config=B.REPORT.ECB,preprocessed=TAG

Specify if the preprocessed tokens should be output.

TAG:

a tag indicating if the preprocessed tokens should be shown. Accepted values are:

  • hide: preprocessed tokens are not shown;

  • show: preprocessed tokens are shown;

Default:

-config=B.REPORT.ECB,preprocessed=hide

Option presumed
presumed
-config=B.REPORT.ECB,presumed=TAG

Specify if the presumed sources should be output.

TAG:

a tag indicating if the presumed sources should be shown. Accepted values are:

  • hide: presumed sources are not shown;

  • show: presumed sources are shown;

Default:

-config=B.REPORT.ECB,presumed=hide

Option tags
tags
-config=B.REPORT.ECB,tags=TAG

Specify if the report tags and their origin should be output.

TAG:

a tag indicating if the report tags should be shown. Accepted values are:

  • hide: report tags are not shown;

  • show: report tags are shown;

Default:

-config=B.REPORT.ECB,tags=hide

Reporter B.REPORT.ERR

Summary

Output B.PARSER error reports in plain text to standard error.

Configuration

See generic service options.

Option output
output
-config=B.REPORT.ERR,output=OUTPUT_FILE

Specify the output destinations of the reports.

OUTPUT_FILE:

the output file name. The pattern @FRAME@ is replaced with current analysis frame number.

Default:

-config=B.REPORT.ERR,output=/dev/stderr

Option includes
includes
-config=B.REPORT.ERR,includes=LEVELS

Specify if the #include chains should be in the report.

LEVELS:

the number of #include chain levels to be shown.

Default:

-config=B.REPORT.ERR,includes=0

Option macros
macros
-config=B.REPORT.ERR,macros=LEVELS

Specify if the expansion chains should be output.

LEVELS:

the number of expansion chain levels to be shown.

Default:

-config=B.REPORT.ERR,macros=10

Option preprocessed
preprocessed
-config=B.REPORT.ERR,preprocessed=TAG

Specify if the preprocessed tokens should be output.

TAG:

a tag indicating if the preprocessed tokens should be shown. Accepted values are:

  • hide: preprocessed tokens are not shown;

  • show: preprocessed tokens are shown;

Default:

-config=B.REPORT.ERR,preprocessed=hide

Option presumed
presumed
-config=B.REPORT.ERR,presumed=TAG

Specify if the presumed sources should be output.

TAG:

a tag indicating if the presumed sources should be shown. Accepted values are:

  • hide: presumed sources are not shown;

  • show: presumed sources are shown;

Default:

-config=B.REPORT.ERR,presumed=hide

Option tags
tags
-config=B.REPORT.ERR,tags=TAG

Specify if the report tags and their origin should be output.

TAG:

a tag indicating if the report tags should be shown. Accepted values are:

  • hide: report tags are not shown;

  • show: report tags are shown;

Default:

-config=B.REPORT.ERR,tags=hide

Option snippet
snippet
-config=B.REPORT.ERR,snippet=NAME

Specify the format of the source text output.

NAME:

the source text output format name. Accepted forms are:

  • hide: don’t show source snippet

  • underline: show underlined source snippet

  • color: show colored source snippet

  • ID: user-defined format

Default:

-config=B.REPORT.ERR,snippet=underline

Reporter B.REPORT.TXT

Summary

Output reports in plain text.

Configuration

See generic service options.

Option output
output
-config=B.REPORT.TXT,output=OUTPUT_FILE

Specify the output destinations of the reports.

OUTPUT_FILE:

the output file name. The pattern @FRAME@ is replaced with current analysis frame number.

Default:

-config=B.REPORT.TXT,output=/dev/stdout

Option includes
includes
-config=B.REPORT.TXT,includes=LEVELS

Specify if the #include chains should be in the report.

LEVELS:

the number of #include chain levels to be shown.

Default:

-config=B.REPORT.TXT,includes=0

Option macros
macros
-config=B.REPORT.TXT,macros=LEVELS

Specify if the expansion chains should be output.

LEVELS:

the number of expansion chain levels to be shown.

Default:

-config=B.REPORT.TXT,macros=0

Option preprocessed
preprocessed
-config=B.REPORT.TXT,preprocessed=TAG

Specify if the preprocessed tokens should be output.

TAG:

a tag indicating if the preprocessed tokens should be shown. Accepted values are:

  • hide: preprocessed tokens are not shown;

  • show: preprocessed tokens are shown;

Default:

-config=B.REPORT.TXT,preprocessed=hide

Option presumed
presumed
-config=B.REPORT.TXT,presumed=TAG

Specify if the presumed sources should be output.

TAG:

a tag indicating if the presumed sources should be shown. Accepted values are:

  • hide: presumed sources are not shown;

  • show: presumed sources are shown;

Default:

-config=B.REPORT.TXT,presumed=hide

Option tags
tags
-config=B.REPORT.TXT,tags=TAG

Specify if the report tags and their origin should be output.

TAG:

a tag indicating if the report tags should be shown. Accepted values are:

  • hide: report tags are not shown;

  • show: report tags are shown;

Default:

-config=B.REPORT.TXT,tags=hide

Option snippet
snippet
-config=B.REPORT.TXT,snippet=NAME

Specify the format of the source text output.

NAME:

the source text output format name. Accepted forms are:

  • hide: don’t show source snippet

  • underline: show underlined source snippet

  • color: show colored source snippet

  • ID: user-defined format

Default:

-config=B.REPORT.TXT,snippet=underline

The BUGSENG Rules

Rule B.AUTOINIT

Summary

Service for checking defassgn and autoinit servants.

Configuration

See generic service options.

Option member_areas
member_areas
-config=B.AUTOINIT,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=B.AUTOINIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=B.AUTOINIT,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule B.BUGFIND.apiModeling.Errno

Summary

Make the special value ‘errno’ available to other checkers.

Configuration

See generic service options.

Rule B.BUGFIND.apiModeling.TrustNonnull

Summary

Trust that returns from framework methods annotated with _Nonnull are not null.

Configuration

See generic service options.

Rule B.BUGFIND.apiModeling.TrustReturnsNonnull

Summary

Trust that returns from methods annotated with returns_nonnull are not null.

Configuration

See generic service options.

Rule B.BUGFIND.apiModeling.google.GTest

Summary

Model gtest assertion APIs.

Configuration

See generic service options.

Rule B.BUGFIND.apiModeling.llvm.CastValue

Summary

Model implementation of custom RTTIs.

Configuration

See generic service options.

Rule B.BUGFIND.apiModeling.llvm.ReturnValue

Summary

Model certain Error() methods that always return true by convention.

Configuration

See generic service options.

Rule B.BUGFIND.core.BitwiseShift

Summary

Finds cases where bitwise shift operation causes undefined behaviour.

Configuration

See generic service options.

Rule B.BUGFIND.core.BoolAssignment

Summary

Warn about assigning non-{0,1} values to Boolean variables.

Configuration

See generic service options.

Rule B.BUGFIND.core.C11Lock

Summary

Simple lock -> unlock checker.

Configuration

See generic service options.

Rule B.BUGFIND.core.CallAndMessage

Summary

Check for logical errors for function calls (e.g., uninitialized arguments, null function pointers).

Configuration

See generic service options.

Rule B.BUGFIND.core.CallAndMessageModeling

Summary

Responsible for essential modeling and assumptions after a function/method call. For instance, if we can’t reason about the nullability of the implicit this parameter after a method call, this checker conservatively assumes it to be non-null.

Configuration

See generic service options.

Rule B.BUGFIND.core.CastSize

Summary

Check when casting a malloc’ed type T, whether the size is a multiple of the size of T.

Configuration

See generic service options.

Rule B.BUGFIND.core.CastToStruct

Summary

Check for cast from non-struct pointer to struct pointer.

Configuration

See generic service options.

Rule B.BUGFIND.core.Conversion

Summary

Loss of sign/precision in implicit conversions.

Configuration

See generic service options.

Rule B.BUGFIND.core.DivideZero

Summary

Check for division by zero.

Configuration

See generic service options.

Rule B.BUGFIND.core.DynamicTypeChecker

Summary

Check for cases where the dynamic and the static type of an object are unrelated.

Configuration

See generic service options.

Rule B.BUGFIND.core.DynamicTypePropagation

Summary

Generate dynamic type information.

Configuration

See generic service options.

Rule B.BUGFIND.core.EnumCastOutOfRange

Summary

Check integer to enumeration casts for out of range values.

Configuration

See generic service options.

Rule B.BUGFIND.core.FixedAddr

Summary

Check for assignment of a fixed address to a pointer.

Configuration

See generic service options.

Rule B.BUGFIND.core.IdenticalExpr

Summary

Warn about unintended use of identical expressions in operators.

Configuration

See generic service options.

Rule B.BUGFIND.core.NonNullParamChecker

Summary

Check for null pointers passed as arguments to a function whose arguments are references or marked with the ‘nonnull’ attribute.

Configuration

See generic service options.

Rule B.BUGFIND.core.NonnilStringConstants

Summary

Assume that const string-like globals are non-null.

Configuration

See generic service options.

Rule B.BUGFIND.core.NullDereference

Summary

Check for dereferences of null pointers.

Configuration

See generic service options.

Rule B.BUGFIND.core.PointerArithm

Summary

Check for pointer arithmetic on locations other than array elements.

Configuration

See generic service options.

Rule B.BUGFIND.core.PointerSub

Summary

Check for pointer subtractions on two pointers pointing to different memory chunks.

Configuration

See generic service options.

Rule B.BUGFIND.core.PthreadLockBase

Summary

Helper registering multiple checks.

Configuration

See generic service options.

Rule B.BUGFIND.core.StackAddrEscapeBase

Summary

Generate information about stack address escapes.

Configuration

See generic service options.

Rule B.BUGFIND.core.StackAddressAsyncEscape

Summary

Check that addresses to stack memory do not escape the function.

Configuration

See generic service options.

Rule B.BUGFIND.core.StackAddressEscape

Summary

Check that addresses to stack memory do not escape the function.

Configuration

See generic service options.

Rule B.BUGFIND.core.StdVariant

Summary

Check for bad type access for std::variant.

Configuration

See generic service options.

Rule B.BUGFIND.core.TestAfterDivZero

Summary

Check for division by variable that is later compared against 0. Either the comparison is useless or there is division by zero.

Configuration

See generic service options.

Rule B.BUGFIND.core.UndefinedBinaryOperatorResult

Summary

Check for undefined results of binary operators.

Configuration

See generic service options.

Rule B.BUGFIND.core.VLASize

Summary

Check for declarations of VLA of undefined or zero size.

Configuration

See generic service options.

Rule B.BUGFIND.core.builtin.BuiltinFunctions

Summary

Evaluate compiler builtin functions (e.g., alloca()).

Configuration

See generic service options.

Rule B.BUGFIND.core.builtin.NoReturnFunctions

Summary

Evaluate “panic” functions that are known to not return to the caller.

Configuration

See generic service options.

Rule B.BUGFIND.core.uninitialized.ArraySubscript

Summary

Check for uninitialized values used as array subscripts.

Configuration

See generic service options.

Rule B.BUGFIND.core.uninitialized.Assign

Summary

Check for assigning uninitialized values.

Configuration

See generic service options.

Rule B.BUGFIND.core.uninitialized.Branch

Summary

Check for uninitialized values used as branch conditions.

Configuration

See generic service options.

Rule B.BUGFIND.core.uninitialized.CapturedBlockVariable

Summary

Check for blocks that capture uninitialized values.

Configuration

See generic service options.

Rule B.BUGFIND.core.uninitialized.NewArraySize

Summary

Check if the size of the array in a new[] expression is undefined.

Configuration

See generic service options.

Rule B.BUGFIND.core.uninitialized.UndefReturn

Summary

Check for uninitialized values being returned to the caller.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.ArrayDelete

Summary

Reports destructions of arrays of polymorphic objects that are destructed as their base class.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.ContainerModeling

Summary

Models C++ containers.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.DeleteWithNonVirtualDtor

Summary

Reports destructions of polymorphic objects with a non-virtual destructor in their base class.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.InnerPointer

Summary

Check for inner pointers of C++ containers used after re/deallocation.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.InvalidatedIterator

Summary

Check for use of invalidated iterators.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.IteratorModeling

Summary

Models iterators of C++ containers.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.IteratorRange

Summary

Check for iterators used outside their valid ranges.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.MismatchedIterator

Summary

Check for use of iterators of different containers where iterators of the same container are expected.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.Move

Summary

Find use-after-move bugs in C++.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.NewDelete

Summary

Check for double-free and use-after-free problems. Traces memory managed by new/delete.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.NewDeleteLeaks

Summary

Check for memory leaks. Traces memory managed by new/delete.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.PlacementNew

Summary

Check if default placement new is provided with pointers to sufficient storage capacity.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.PureVirtualCall

Summary

Check pure virtual function calls during construction/destruction.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.STLAlgorithmModeling

Summary

Models the algorithm library of the C++ STL.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.SelfAssignment

Summary

Checks C++ copy and move assignment operators for self assignment.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.SmartPtr

Summary

Find the dereference of null SmrtPtr.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.SmartPtrModeling

Summary

Model behavior of C++ smart pointers.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.StringChecker

Summary

Checks C++ std::string bugs.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.UninitializedObject

Summary

Reports uninitialized fields after object construction.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.VirtualCall

Summary

Check virtual function calls during construction/destruction.

Configuration

See generic service options.

Rule B.BUGFIND.cplusplus.VirtualCallModeling

Summary

Auxiliary modeling for the virtual method call checkers.

Configuration

See generic service options.

Rule B.BUGFIND.deadcode.DeadStores

Summary

Check for values stored to variables that are never read afterwards.

Configuration

See generic service options.

Rule B.BUGFIND.deadcode.UnreachableCode

Summary

Check unreachable code.

Configuration

See generic service options.

Rule B.BUGFIND.nondeterminism.PointerIteration

Summary

Checks for non-determinism caused by iteration of unordered containers of pointers.

Configuration

See generic service options.

Rule B.BUGFIND.nondeterminism.PointerSorting

Summary

Check for non-determinism caused by sorting of pointers.

Configuration

See generic service options.

Rule B.BUGFIND.nullability.NullPassedToNonnull

Summary

Warns when a null pointer is passed to a pointer which has a _Nonnull type.

Configuration

See generic service options.

Rule B.BUGFIND.nullability.NullReturnedFromNonnull

Summary

Warns when a null pointer is returned from a function that has _Nonnull return type.

Configuration

See generic service options.

Rule B.BUGFIND.nullability.NullabilityBase

Summary

Stores information during the analysis about nullability.

Configuration

See generic service options.

Rule B.BUGFIND.nullability.NullableDereferenced

Summary

Warns when a nullable pointer is dereferenced.

Configuration

See generic service options.

Rule B.BUGFIND.nullability.NullablePassedToNonnull

Summary

Warns when a nullable pointer is passed to a pointer which has a _Nonnull type.

Configuration

See generic service options.

Rule B.BUGFIND.nullability.NullableReturnedFromNonnull

Summary

Warns when a nullable pointer is returned from a function that has _Nonnull return type.

Configuration

See generic service options.

Rule B.BUGFIND.performance.GCDAntipattern

Summary

Check for performance anti-patterns when using Grand Central Dispatch.

Configuration

See generic service options.

Rule B.BUGFIND.performance.Padding

Summary

Check for excessively padded structs.

Configuration

See generic service options.

Rule B.BUGFIND.portability.UnixAPI

Summary

Finds implementation-defined behavior in UNIX/Posix functions.

Configuration

See generic service options.

Rule B.BUGFIND.security.ArrayBound

Summary

Warn about buffer overflows.

Configuration

See generic service options.

Rule B.BUGFIND.security.ArrayBoundV2

Summary

Warn about buffer overflows.

Configuration

See generic service options.

Rule B.BUGFIND.security.FloatLoopCounter

Summary

Warn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP).

Configuration

See generic service options.

Rule B.BUGFIND.security.MmapWriteExec

Summary

Warn on mmap() calls with both writable and executable access.

Configuration

See generic service options.

Rule B.BUGFIND.security.PutenvStackArray

Summary

Finds calls to the function ‘putenv’ which pass a pointer to an automatic (stack-allocated) array as the argument.

Configuration

See generic service options.

Rule B.BUGFIND.security.ReturnPtrRange

Summary

Check for an out-of-bound pointer being returned to callers.

Configuration

See generic service options.

Rule B.BUGFIND.security.SetgidSetuidOrder

Summary

Warn on possible reversed order of ‘setgid(getgid()))’ and ‘setuid(getuid())’ (CERT: POS36-C).

Configuration

See generic service options.

Rule B.BUGFIND.security.cert.env.InvalidPtr

Summary

Finds usages of possibly invalidated pointers.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.DeprecatedOrUnsafeBufferHandling

Summary

Warn on uses of unsecure or deprecated buffer manipulating functions.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.SecuritySyntaxChecker

Summary

Base of various security function related checkers.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.UncheckedReturn

Summary

Warn on uses of functions whose return values must be always checked.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.bcmp

Summary

Warn on uses of the ‘bcmp’ function.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.bcopy

Summary

Warn on uses of the ‘bcopy’ function.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.bzero

Summary

Warn on uses of the ‘bzero’ function.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.getpw

Summary

Warn on uses of the ‘getpw’ function.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.gets

Summary

Warn on uses of the ‘gets’ function.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.mkstemp

Summary

Warn when ‘mkstemp’ is passed fewer than 6 X’s in the format string.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.mktemp

Summary

Warn on uses of the ‘mktemp’ function.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.rand

Summary

Warn on uses of the ‘rand’, ‘random’, and related functions.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.strcpy

Summary

Warn on uses of the ‘strcpy’ and ‘strcat’ functions.

Configuration

See generic service options.

Rule B.BUGFIND.security.insecureAPI.vfork

Summary

Warn on uses of the ‘vfork’ function.

Configuration

See generic service options.

Rule B.BUGFIND.security.taint.GenericTaint

Summary

Reports potential injection vulnerabilities.

Configuration

See generic service options.

Rule B.BUGFIND.security.taint.TaintPropagation

Summary

Generate taint information used by other checkers.

Configuration

See generic service options.

Rule B.BUGFIND.taint.TaintedAlloc

Summary

Check for memory allocations, where the size parameter might be a tainted (attacker controlled) value.

Configuration

See generic service options.

Rule B.BUGFIND.unix.API

Summary

Check calls to various UNIX/Posix functions.

Configuration

See generic service options.

Rule B.BUGFIND.unix.BlockInCriticalSection

Summary

Check for calls to blocking functions inside a critical section.

Configuration

See generic service options.

Rule B.BUGFIND.unix.Chroot

Summary

Check improper use of chroot.

Configuration

See generic service options.

Rule B.BUGFIND.unix.DynamicMemoryModeling

Summary

The base of several malloc() related checkers. On its own it emits no reports, but adds valuable information to the analysis when enabled.

Configuration

See generic service options.

Rule B.BUGFIND.unix.Errno

Summary

Check for improper use of ‘errno’.

Configuration

See generic service options.

Rule B.BUGFIND.unix.Malloc

Summary

Check for memory leaks, double free, and use-after-free problems. Traces memory managed by malloc()/free().

Configuration

See generic service options.

Rule B.BUGFIND.unix.MallocSizeof

Summary

Check for dubious malloc arguments involving sizeof.

Configuration

See generic service options.

Rule B.BUGFIND.unix.MismatchedDeallocator

Summary

Check for mismatched deallocators.

Configuration

See generic service options.

Rule B.BUGFIND.unix.PthreadLock

Summary

Simple lock -> unlock checker.

Configuration

See generic service options.

Rule B.BUGFIND.unix.SimpleStream

Summary

Check for misuses of stream APIs.

Configuration

See generic service options.

Rule B.BUGFIND.unix.StdCLibraryFunctions

Summary

Check for invalid arguments of C standard library functions, and apply relations between arguments and return value.

Configuration

See generic service options.

Rule B.BUGFIND.unix.Stream

Summary

Check stream handling functions.

Configuration

See generic service options.

Rule B.BUGFIND.unix.Vfork

Summary

Check for proper usage of vfork.

Configuration

See generic service options.

Rule B.BUGFIND.unix.cstring.BadSizeArg

Summary

Check the size argument passed into C string functions for common erroneous patterns.

Configuration

See generic service options.

Rule B.BUGFIND.unix.cstring.BufferOverlap

Summary

Checks for overlap in two buffer arguments.

Configuration

See generic service options.

Rule B.BUGFIND.unix.cstring.CStringModeling

Summary

The base of several CString related checkers. On its own it emits no reports, but adds valuable information to the analysis when enabled.

Configuration

See generic service options.

Rule B.BUGFIND.unix.cstring.NotNullTerminated

Summary

Check for arguments which are not null-terminating strings.

Configuration

See generic service options.

Rule B.BUGFIND.unix.cstring.NullArg

Summary

Check for null pointers being passed as arguments to C string functions.

Configuration

See generic service options.

Rule B.BUGFIND.unix.cstring.OutOfBounds

Summary

Check for out-of-bounds access in string functions.

Configuration

See generic service options.

Rule B.BUGFIND.unix.cstring.UninitializedRead

Summary

Checks if the string manipulation function would read uninitialized bytes.

Configuration

See generic service options.

Rule B.BUGFIND.valist.CopyToSelf

Summary

Check for va_lists which are copied onto itself.

Configuration

See generic service options.

Rule B.BUGFIND.valist.Uninitialized

Summary

Check for usages of uninitialized (or already released) va_lists.

Configuration

See generic service options.

Rule B.BUGFIND.valist.Unterminated

Summary

Check for va_lists which are not released by a va_end call.

Configuration

See generic service options.

Rule B.BUGFIND.valist.ValistBase

Summary

Gathers information about va_lists.

Configuration

See generic service options.

Rule B.CALL.noeffect

Summary

Reports functions declared with wrong or missing effects-related property.

Description

The service reports each function not labelled with the strictest possible pureness impact property or functions labelled with a not-respected pureness property.

The pureness impact properties are:

  • noeffect;

  • pure;

  • fp_const;

  • const.

In particular the service reports:

  • if a function is declared noeffect and:

    • calls a function not declared noeffect;

    • has indirect calls;

    • may throw an exception that is not caught within the function;

    • calls new, delete, a non-trivial constructor or a destructor;

    • writes to a variable that is volatile or has static storage; or

    • reads a volatile variable that triggers side effects;

  • if a function is declared pure:

    • all the situations reported for noeffect;

    • if it calls functions not being pure;

    • if it reads from a volatile variable;

  • if a function is declared const:

    • all the situations reported for pure;

    • if it calls functions not being const;

    • if it read a variable without automatic storage;

  • conversions from a certain function type to another with a less strict property that does not concern formal parameters types in function overridings (contravariance principle).

  • in conversion between formal parameters types due to function overloading, any conversion from a certain function type to another with a stricter property.

Notes:

  • where supported by the standard, the pureness properties pure and const can be assigned to a function using the attribute specifier. For example:

void f() __attribute__((pure));
  • alternatively, a function can be assigned a property using -call_properties global configuration. For example:

-call_properties+={"type(^pure_fun_t$)", {pure}}
-call_properties+={"name(no_effect_f)", {noeffect}}
  • any overriding of a virtual function inherits the property of the overridden function.

  • destructors and virtual non-final methods are not checked;

  • the impacts service configuration can be used to tag reports for functions where the pureness property of the body is stricter than the declared property.

Imprecision

if the analyzer is uncertain whether a type that does not have the noeffect property could be converted to a function type with the noeffect property

A call to a function not declared noeffect is considered a side effect even if, with the given arguments, it cannot cause any observable side effects.

Configuration

See generic service options.

Option impacts
impacts
-config=B.CALL.noeffect,impacts={TAGS, PROP_MATCHER},...

Associates a set of tags to a matching pair of impact properties (the function’s declared impact and the inferred body’s impact).

The configuration’s content is list of pairs of a set of report taggers with a impacts matcher.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PROP_MATCHER:

an expression defining the matching impacts. Accepted forms are:

  • [+]AND_MATCHER: the property pair matches AND_MATCHER

  • -AND_MATCHER: the property pair does not match AND_MATCHER

  • [+]AND_MATCHER||PROP_MATCHER: either the property pair matches AND_MATCHER or it matches PROP_MATCHER

  • -AND_MATCHER||PROP_MATCHER: the property pair does not match AND_MATCHER but does match PROP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the property pair matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the property pair matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PROP_MATCHER): the property pair matches PROP_MATCHER

  • !BASIC_MATCHER: the property pair does not match BASIC_MATCHER

  • any(): any property pair matches

  • none(): no property pair matches

  • decl([REL]IMPACTS): the declared property must be in a strictness relation REL with IMPACTS; if no relation is specified, the declared property must be the same as IMPACTS

  • body([REL]IMPACTS): the body’s property must be in a strictness relation REL with IMPACTS; if no relation is specified, the body’s property must be the same as IMPACTS

IMPACTS

accepted forms are:

  • IMPACT[||IMPACT]*): one of the IMPACTs

IMPACT

accepted forms are:

  • const: call is const. That is, it is assumed that the called function is const

  • fp_const: the floating-point environment is unchanged and the call is const

  • pure: call is pure. That is, it is assumed that the called function is pure

  • noeffect: a call to a function with no external side effect. That is, it is assumed that: there are no indirect calls; any throw is caught within the function; there are no calls to new, delete, a non-trivial constructor or a destructor; it does not write to a variable that is volatile or has static storage; and it does not read from a volatile variable that triggers a side effects

  • nothrow: a call to a function for which it is assumed that any thrown exceptions are caught within the function

  • any: the call can have any impact

REL

accepted forms are:

  • =: the same

  • >: less strict

  • >=: the same or less strict

  • <: stricter

  • <=: the same or stricter

Default:

-config=B.CALL.noeffect,impacts={hide, "body(noeffect)"}

Option declarations
declarations
-config=B.CALL.noeffect,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule B.CALL.nothrow

Summary

Reports functions with wrong nothrow property.

Description

The service reports each function labelled with the nothrow impact property:

  • if it has an uncaught throw;

  • if it calls a function that does not have the nothrow property and does not have a catch-all for that call;

  • if a type that does not have the nothrow property is converted to a function type with the nothrow property.

Notes:

  • A function has the impact property nothrow if it is declared with a noexcept-specifier to not throw exceptions or it is specified as nothrow using -call_properties global configuration;

  • A destructor could be called implicitly from stack deallocation, if it occurs after the completing the initialization of an exception object but before activation of a handler for the exception and cause a call to terminate(). For this reason, the service reports all the destructors with possible exceptions.

  • the impacts service configuration can be used to tag reports about functions where the declared property is less strict than the body’s property

Using the default configuration of the impacts service configuration, functions with the nothrow property, but not declared as such are not reported. This can be changed by setting the properties service configuration.

Imprecision

The following cases are reported as cautions if not handled with a catch-all block:

  • implicit and explicit calls to functions that do not have the property nothrow;

  • implicit calls to destructors due to the stack deallocation;

  • typeid expressions on polymorphic arguments;

  • dynamic_cast expressions.

  • if the analyzer is uncertain whether a type that does not have the nothrow property could be converted to a function type with the nothrow property

Configuration

See generic service options.

Option impacts
impacts
-config=B.CALL.nothrow,impacts={TAGS, PROP_MATCHER},...

Associates a set of tags to a matching pair of impact properties (the function’s declared impact and the inferred body’s impact).

The configuration’s content is list of pairs of a set of report taggers with a impacts matcher.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PROP_MATCHER:

an expression defining the matching impacts. Accepted forms are:

  • [+]AND_MATCHER: the property pair matches AND_MATCHER

  • -AND_MATCHER: the property pair does not match AND_MATCHER

  • [+]AND_MATCHER||PROP_MATCHER: either the property pair matches AND_MATCHER or it matches PROP_MATCHER

  • -AND_MATCHER||PROP_MATCHER: the property pair does not match AND_MATCHER but does match PROP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the property pair matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the property pair matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PROP_MATCHER): the property pair matches PROP_MATCHER

  • !BASIC_MATCHER: the property pair does not match BASIC_MATCHER

  • any(): any property pair matches

  • none(): no property pair matches

  • decl([REL]IMPACTS): the declared property must be in a strictness relation REL with IMPACTS; if no relation is specified, the declared property must be the same as IMPACTS

  • body([REL]IMPACTS): the body’s property must be in a strictness relation REL with IMPACTS; if no relation is specified, the body’s property must be the same as IMPACTS

IMPACTS

accepted forms are:

  • IMPACT[||IMPACT]*): one of the IMPACTs

IMPACT

accepted forms are:

  • const: call is const. That is, it is assumed that the called function is const

  • fp_const: the floating-point environment is unchanged and the call is const

  • pure: call is pure. That is, it is assumed that the called function is pure

  • noeffect: a call to a function with no external side effect. That is, it is assumed that: there are no indirect calls; any throw is caught within the function; there are no calls to new, delete, a non-trivial constructor or a destructor; it does not write to a variable that is volatile or has static storage; and it does not read from a volatile variable that triggers a side effects

  • nothrow: a call to a function for which it is assumed that any thrown exceptions are caught within the function

  • any: the call can have any impact

REL

accepted forms are:

  • =: the same

  • >: less strict

  • >=: the same or less strict

  • <: stricter

  • <=: the same or stricter

Default:

-config=B.CALL.nothrow,impacts={hide, "any()"}

Option declarations
declarations
-config=B.CALL.nothrow,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule B.CFBODY

Summary

Uncontrolled function bodies are shown.

Configuration

See generic service options.

Rule B.CMNTVCBL

Summary

The vocabulary used for code comments should be precisely defined in a way that is amenable to automatic checking.

Description

Reports if code comments do not use the defined vocabulary. See vocabulary for more information about the vocabulary dictionaries and their use

Configuration

See generic service options.

Option comments
comments
-config=B.CMNTVCBL,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option project_dictionary
project_dictionary
-config=B.CMNTVCBL,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=B.CMNTVCBL,project_dictionary=""

Option context_dictionary
context_dictionary
-config=B.CMNTVCBL,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=B.CMNTVCBL,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=B.CMNTVCBL,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=B.CMNTVCBL,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=B.CMNTVCBL,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=B.CMNTVCBL,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=B.CMNTVCBL,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=B.CMNTVCBL,max_no_case_length=16

Option good_words_file
good_words_file
-config=B.CMNTVCBL,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=B.CMNTVCBL,good_words_file=""

Option bad_words_file
bad_words_file
-config=B.CMNTVCBL,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=B.CMNTVCBL,bad_words_file=""

Option good_items_file
good_items_file
-config=B.CMNTVCBL,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=B.CMNTVCBL,good_items_file=""

Option bad_items_file
bad_items_file
-config=B.CMNTVCBL,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=B.CMNTVCBL,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=B.CMNTVCBL,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=B.CMNTVCBL,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=B.CMNTVCBL,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=B.CMNTVCBL,bad_item_regexs={}

Option comment_regexs
comment_regexs
-config=B.CMNTVCBL,comment_regexs=SPLITTER,...

A list of regular expressions defining comment splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

  • SPLITTER: regular expression defining a custom splitter.


Option ignored_comments
ignored_comments
-config=B.CMNTVCBL,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule B.CMPREXPR-01

Summary

In an equality test, if the second operand is not an lvalue then the first operand is not an lvalue.

Configuration

See generic service options.

Option statements
statements
-config=B.CMPREXPR-01,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=B.CMPREXPR-01,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule B.CMPREXPR-02

Summary

String literals shall not be arguments of relational and equality operators.

Configuration

See generic service options.

Option statements
statements
-config=B.CMPREXPR-02,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=B.CMPREXPR-02,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule B.COLLDICT

Summary

Collects dictionaries to be used for defining and checking program vocabularies.

Description

Collects the project vocabulary and creates a dictionary. See vocabulary for more information about the vocabulary dictionaries and their use

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=B.COLLDICT,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=B.COLLDICT,project_dictionary=""

Option context_dictionary
context_dictionary
-config=B.COLLDICT,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=B.COLLDICT,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=B.COLLDICT,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=B.COLLDICT,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=B.COLLDICT,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=B.COLLDICT,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=B.COLLDICT,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=B.COLLDICT,max_no_case_length=16

Option output_dictionary
output_dictionary
-config=B.COLLDICT,output_dictionary=OUTPUT_DICT

The output dictionary: for outputting the collected list of words used in the project, along with their frequencies.

OUTPUT_DICT:

output dictionary filename.

Default:

-config=B.COLLDICT,output_dictionary=""

Rule B.ECLRVLDT

Summary

Files not validated by ECLAIR with the given configuration are shown.

Configuration

See generic service options.

Rule B.ENTTRFRN

Summary

A program should not contain unreferenced entities.

Description

Every project must define all (documented and undocumented) entry points using the -extra_references global configuration.

Reports entities that are unused or unreferenced where:

  • an entity is referenced if (apart from its definition) it appears in the program code;

  • an entity is used if is referenced from an entry point entity or an ancestor entity or an entity already found to be used.

Implementation

An entity can be shown during unit work if its visibility is not the whole program.

Configuration

See generic service options.

Option declarations
declarations
-config=B.ENTTRFRN,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=B.ENTTRFRN,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule B.EXPRPRNS

Summary

Parentheses shall be used in expressions to clarify code.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=B.EXPRPRNS,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule B.FORCNTRL

Summary

For statements that cannot be guaranteed to terminate are shown.

Configuration

See generic service options.

Option for_structure
for_structure
-config=B.FORCNTRL,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=B.FORCNTRL,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=B.FORCNTRL,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule B.GLOBALVAR

Summary

Global variables shall not be declared.

Description

Reports global variables

Configuration

See generic service options.

Option declarations
declarations
-config=B.GLOBALVAR,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule B.IDB_TIE

Summary

Rule for tying and summarizing any of the IDB ancillary servants. This service depends upon the configuration of the following ancillary services: STD.abortbhr STD.asrtterm STD.bitfldby STD.bitfldor STD.bitfldtp STD.bitopsgn STD.bytebits STD.caselimt STD.charlcle STD.charmmap STD.charmult STD.charppif STD.charppim STD.charsmap STD.charsmem STD.charsobj STD.charsval STD.clockera STD.cmralloc STD.ctypechr STD.datetime STD.decllimt STD.diagidnt STD.divrmsgn STD.enumtype STD.errnofgt STD.exitstat STD.extidsig STD.extinttp STD.feraisex STD.filebuff STD.filemopn STD.fileposi STD.fimename STD.floatcct STD.floatcst STD.floatexc STD.floatiex STD.floatnrw STD.floatrnd STD.floatstd STD.floatunf STD.floatval STD.fltevmth STD.fltevtyp STD.fmodzero STD.fprintfp STD.freesten STD.freestnd STD.fscanfms STD.fscanfp STD.getenvfn STD.inclangl STD.inclexpd STD.inclfile STD.inclhead STD.intfloat STD.intrpntr STD.intvdevc STD.mainargv STD.maindefn STD.mathdmer STD.mathrner STD.mathrond STD.multbchr STD.multbtid STD.multbtsl STD.nexidsig STD.nullchar STD.nullpntr STD.objbytes STD.plainbit STD.planchar STD.pragmdir STD.pragmfpc STD.pragmfva STD.pragmhdr STD.ptrdifft STD.register STD.removefl STD.remquofn STD.renamefl STD.rtsigned STD.setlocle STD.shortsgn STD.signalbk STD.signalfn STD.signalsl STD.signalsm STD.signalst STD.signdint STD.sizettyp STD.spacechr STD.stdmacro STD.strerror STD.stringfy STD.strtwcst STD.strtwcsu STD.structma STD.systemfn STD.textterm STD.timelocl STD.unionmbr STD.vaendmi STD.volatltp STD.widechar STD.widestng STD.witespac STD.writetxt STD.zerolnfl

Configuration

See generic service options.

Option behaviors
behaviors
-config=B.IDB_TIE,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=B.IDB_TIE,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=B.IDB_TIE,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule B.IDNTVCBL

Summary

The vocabulary used to compose identifiers should be precisely defined in a way that is amenable to automatic checking.

Description

Reports if entity names do not use the defined vocabulary. See vocabulary for more information about the vocabulary dictionaries and their use

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=B.IDNTVCBL,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=B.IDNTVCBL,project_dictionary=""

Option context_dictionary
context_dictionary
-config=B.IDNTVCBL,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=B.IDNTVCBL,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=B.IDNTVCBL,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=B.IDNTVCBL,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=B.IDNTVCBL,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=B.IDNTVCBL,segmentation_stops_after=none

Option max_no_case_length
max_no_case_length
-config=B.IDNTVCBL,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=B.IDNTVCBL,max_no_case_length=16

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=B.IDNTVCBL,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=B.IDNTVCBL,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=B.IDNTVCBL,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=B.IDNTVCBL,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=B.IDNTVCBL,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=B.IDNTVCBL,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=B.IDNTVCBL,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option good_words_file
good_words_file
-config=B.IDNTVCBL,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=B.IDNTVCBL,good_words_file=""

Option bad_words_file
bad_words_file
-config=B.IDNTVCBL,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=B.IDNTVCBL,bad_words_file=""

Option good_items_file
good_items_file
-config=B.IDNTVCBL,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=B.IDNTVCBL,good_items_file=""

Option bad_items_file
bad_items_file
-config=B.IDNTVCBL,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=B.IDNTVCBL,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=B.IDNTVCBL,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=B.IDNTVCBL,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=B.IDNTVCBL,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=B.IDNTVCBL,bad_item_regexs={}

Rule B.INDEPENDENCE

Aliases

B.PROJORG

Summary

Files, entities and macros shall satisfy the configured project organization constraints.

Description

For general information about this tool and some illustrative examples, see Keeping the Project Organization Under Control.

Configuration

See generic service options.

Option component_files
component_files
-config=B.INDEPENDENCE,component_files={FMT, FILE_MATCHER},...

Specifies that matching files are in the component defined by the format.

The configuration’s content is format and matcher for the component file names.

FMT:

format (see the -fmt global configuration content, template independence__file_default_fmt, specifying a mapping from a file to its component base name/area; this has fields:

name

file base name without extension;

extension

file name extension;

kind

file kind.

FILE_MATCHER:

a -file_tag identifier or a matcher expression used to select the files.

Default:

-config=B.INDEPENDENCE,component_files={}

Option all_component_entities
all_component_entities
-config=B.INDEPENDENCE,all_component_entities=ENTITY_MATCHER,...

Specifies that matching entities are interesting.

The configuration’s content is a set of entity matchers defining the universe of all interesting entities.

ENTITY_MATCHER:

an -entity_selector identifier or a matcher expression used to select the entities.

Default:

-config=B.INDEPENDENCE,all_component_entities={}

Option component_entities
component_entities
-config=B.INDEPENDENCE,component_entities={FMT, TRACKER, ENTITY_MATCHER},...

Specifies that matching entities with given tracking are in the component/area defined by the format.

The configuration’s content is a sequence of entity matchers with assigned tracking and component format; note that matchers that constrain the entity name will be checked before the more generic ones.

FMT:

format (see the -fmt global configuration content, template independence__entity_default_fmt), specifying a mapping from an entity to its component/area; this has fields:

name

entity name without qualifiers;

fqname

fully qualified entity name;

kind

entity kind.

TRACKER:

tracking determines the accesses to the matching entities. Accepted values are:

  • content: the accesses are to references to matching variables or functions;

  • field: the accesses are to references to matching fields;

  • address: the accesses are to the addresses of tracked pointees to references to matching variables;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select a subset of the interesting entities (selected using all_component_entities).

Default:

-config=B.INDEPENDENCE,component_entities={}

Option all_component_macros
all_component_macros
-config=B.INDEPENDENCE,all_component_macros=MACRO_MATCHER,...

Specifies that matching macros are interesting.

The configuration’s content is a set of macro matchers defining the universe of all interesting macros.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

Default:

-config=B.INDEPENDENCE,all_component_macros={}

Option component_macros
component_macros
-config=B.INDEPENDENCE,component_macros={FMT, TRACKER, MACRO_MATCHER},...

Specifies that matching macros with given tracking are in the component defined by the format.

The configuration’s content is a short-circuit sequence of macro matchers with assigned tracking and component format.

FMT:

format (see the -fmt global configuration content, template independence__macro_default_fmt), specifying a mapping from a macro to its component base name/area; this has fields:

name

entity name without qualifiers;

function_like

boolean for selecting function-like (true) or object-like (false) macros;

variadic

boolean for selecting variadic (true) or non-variadic (false) macros;

used

boolean for selecting macros that are used (true) or unused (false);

guard

boolean for selecting macros that are used (true) or not used for guards (false).

TRACKER:

tracking determines the referrer; that is, who is responsible for the expansion. Accepted values are:

  • macro_file: if expanded in the body of a macro, use that macro; otherwise use the component for the file containing the expansion;

  • macro_entity: if expanded in the body of a macro, use that macro; if expanded in an entity, then use the entity;

  • entity: use entity of the top expansion;

  • address: if the macro expands to a possibly wrapped integer literal, use the innermost entity that contains the literal; it is checked that there is a possible read of the literal as an address;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select a subset of the interesting macros (selected using all_component_macros).

Default:

-config=B.INDEPENDENCE,component_macros={}

Option component_tag
component_tag
-config=B.INDEPENDENCE,component_tag={COMP_MATCHER_T, DOMAIN, TAG},...

Specifies a matching component’s domain and tag; the assigned domains classify the components while the tags can provide a security mark or level.

The configuration’s content is a short-circuit sequence of component matchers with associated domains and tags.

COMP_MATCHER_T:

component matcher for specifying the domain and tag. Accepted forms are:

  • [+]AND_MATCHER: the component matches AND_MATCHER

  • -AND_MATCHER: the component does not match AND_MATCHER

  • [+]AND_MATCHER||COMP_MATCHER_T: either the component matches AND_MATCHER or it matches COMP_MATCHER_T

  • -AND_MATCHER||COMP_MATCHER_T: the component does not match AND_MATCHER but does match COMP_MATCHER_T

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the component matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the component matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COMP_MATCHER_T): the component matches COMP_MATCHER_T

  • !COMP_MATCHER_T: the component does not match COMP_MATCHER_T

  • any(): any component matches

  • none(): no component matches

  • ID: component base name

  • ^REGEX$: the component base name matches ^REGEX$

REGEX

accepted forms are:

DOMAIN:

a domain identifier.

TAG:

a tag identifier or number in DOMAIN.

Default:

-config=B.INDEPENDENCE,component_tag={}

Option component_relation
component_relation
-config=B.INDEPENDENCE,component_relation={COMP_MATCHER_R, REL, COMP_MATCHER_R},...

Specifies the relation between matching from (or referring) components and matching to (or referred) components.

The configuration’s content is the relations between components.

COMP_MATCHER_R:

component matcher for specifying the from (referring) component. Accepted forms are:

  • [+]AND_MATCHER: the component matches AND_MATCHER

  • -AND_MATCHER: the component does not match AND_MATCHER

  • [+]AND_MATCHER||COMP_MATCHER_R: either the component matches AND_MATCHER or it matches COMP_MATCHER_R

  • -AND_MATCHER||COMP_MATCHER_R: the component does not match AND_MATCHER but does match COMP_MATCHER_R

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the component matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the component matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COMP_MATCHER_R): the component matches COMP_MATCHER_R

  • !COMP_MATCHER_R: the component does not match COMP_MATCHER_R

  • any(): any component matches

  • none(): no component matches

  • ID: component base name

  • tag(DOMAIN_IDOPVALUE_ID): first component for which DOMAIN_ID OP VALUE_ID holds

  • tag(DOMAIN_ID=^REGEX$): first component for which DOMAIN_ID matches REGEX

REGEX

accepted forms are:

OP

accepted forms are:

  • ==: tags are identical

  • !=: tags differ

  • <: the first tag is less than the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

  • <=: the first tag is less than or equal to the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

  • >: the first tag is greater than the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

  • >=: the first tag is greater than or equal to the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

REL:

relation identifier.

COMP_MATCHER_R:

component matcher for specifying the to (referred) component.

Default:

-config=B.INDEPENDENCE,component_relation={}

Option show_component_files
show_component_files
-config=B.INDEPENDENCE,show_component_files=COMP_MATCHERS,...

Specifies files and their components to be shown.

{COMP_MATCHERS,…}:

files whose components match one of COMP_MATCHERS are shown. Accepted members are:

  • COMP_MATCHER: component matcher. Accepted forms are:

  • [+]AND_MATCHER: the component matches AND_MATCHER

  • -AND_MATCHER: the component does not match AND_MATCHER

  • [+]AND_MATCHER||COMP_MATCHER: either the component matches AND_MATCHER or it matches COMP_MATCHER

  • -AND_MATCHER||COMP_MATCHER: the component does not match AND_MATCHER but does match COMP_MATCHER_R

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the component matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the component matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COMP_MATCHER): the component matches COMP_MATCHER

  • !COMP_MATCHER: the component does not match COMP_MATCHER

  • COMP_MATCHER_R: the component matches COMP_MATCHER_R

  • ID1/ID2: the component’s full name is ID1/ID2

  • rel(RELS,COMP_MATCHER): the component being matched is in a relation in RELS with a component matching COMP_MATCHER

  • irel(RELS,COMP_MATCHER): a component matching COMP_MATCHER is in a relation in RELS with the component being matched

  • ^REGEX$: the component full name matches ^REGEX$

REGEX

accepted forms are:

RELS

accepted forms are:

  • ID[||ID]*: relation is one of ID that is defined by parameter component_relation


Option show_component_entities
show_component_entities
-config=B.INDEPENDENCE,show_component_entities=COMP_MATCHERS,...

Specifies entities and their components to be shown.

{COMP_MATCHERS,…}:

entities whose components match one of the COMP_MATCHERS are shown. Accepted members are:

  • COMP_MATCHER: component matcher.


Option show_component_macros
show_component_macros
-config=B.INDEPENDENCE,show_component_macros=COMP_MATCHERS,...

Specifies macros and their components to be shown.

{COMP_MATCHERS,…}:

macros whose components match one of the COMP_MATCHERS are shown. Accepted members are:

  • COMP_MATCHER: component matcher.


Option relation_report
relation_report
-config=B.INDEPENDENCE,relation_report={PERM_MATCHER, REPORT_KIND},...

Specifies the components’ permissions and associated report kinds.

The configuration’s content is a short-circuit sequence of permission matchers with report kinds.

PERM_MATCHER:

permission matcher. Accepted forms are:

  • [+]AND_MATCHER: the permission matches AND_MATCHER

  • -AND_MATCHER: the permission does not match AND_MATCHER

  • [+]AND_MATCHER||PERM_MATCHER: either the permission matches AND_MATCHER or it matches PERM_MATCHER

  • -AND_MATCHER||PERM_MATCHER: the permission does not match AND_MATCHER but does match PERM_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the permission matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the permission matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PERM_MATCHER): the permission matches PERM_MATCHER

  • !BASIC_MATCHER: the permission does not match BASIC_MATCHER

  • any(): any permission matches

  • none(): no permission matches

  • from(COMP_MATCHER): the referring component matches COMP_MATCHER

  • to(COMP_MATCHER): the referred component matches COMP_MATCHER

  • action(ACTION[||ACTION]*): the action matches one of the ACTION tags

  • rels(ID[||ID]*): the relation between the referred and referring components matches one of the ID

  • tag(Id0OPId1): the tag for the domain Id0 of the referring component is OP the tag for the domain Id1 of the referred component

ACTION

accepted forms are:

  • read: the component tracks an entity that is read

  • write: the referred component tracks an entity that is written

  • call: the referred component tracks a function that is called

  • expand: the referred component tracks a macro that is expanded

  • include: the referred component contains a file that is included

OP

accepted forms are:

  • ==: tags are identical

  • !=: tags differ

  • <: the first tag is less than the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

  • <=: the first tag is less than or equal to the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

  • >: the first tag is greater than the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

  • >=: the first tag is greater than or equal to the second (using numerical ordering if both are numeric, otherwise using lexicographic ordering)

REPORT_KIND:

report kind. Accepted values are:

  • violation: report is shown as a violation;

  • caution: report is shown as a caution;

  • information: report is shown as an information;

  • '': the report is not shown;

Default:

-config=B.INDEPENDENCE,relation_report={}

Option component_allows
component_allows
-config=B.INDEPENDENCE,component_allows=PERM_MATCHER,...

Specifies the allowed relations between the referred and referring components.

The configuration’s content is a short-circuit sequence of permission matchers.

PERM_MATCHER:

any relation between the referred and referring components that matches PERM_MATCHER is allowed.

Default:

-config=B.INDEPENDENCE,component_allows={}

Rule B.INITDEST

Summary

Checker for initialization destinations.

Configuration

See generic service options.

Rule B.LIMITS

Summary

Source code should not breach the implementation’s limits.

Description

The source code must not breach the implementation’s limits.

This service depends upon the configuration of the following ancillary services: STD.argfcall STD.argmcall STD.blkident STD.byteobjt STD.caselimt STD.charline STD.charstrl STD.cissnest STD.cnstenum STD.extident STD.extidsig STD.inclnest STD.macident STD.membrecd STD.nexidsig STD.paramfun STD.parammac STD.pexpnest STD.ppifnest STD.ptypnest STD.recdnest STD.decllimt

Configuration

See generic service options.

Option behaviors
behaviors
-config=B.LIMITS,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule B.MACREXPR

Summary

A macro invocation that expands to a sequence of tokens starting and ending on expression edges must be parenthesized or immediately enclosed in parentheses.

Description

Any macro expansion that is a complete expression must be parenthesized or immediately enclosed in parentheses.

Any macro expansion that does not expand to an expression but begins and ends with sub-expressions of a single larger expression is reported. Notes:

  • The following expansions are not reported:

    • a parenthesized expression

    • a call-like expression

    • a single token expression

    • an initializer list

    • an expression whose value is ignored

  • The expansion_context service configuration can be used to tag the reports for macro calls that expand to nodes with matching contexts.

Configuration

See generic service options.

Option macros
macros
-config=B.MACREXPR,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option expansion_context
expansion_context
-config=B.MACREXPR,expansion_context={TAGS, MATCHER},...

Specify the report tag for associated expansion context matcher.

The configuration’s content is list of report tags and their associated expansion matcher option.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

expansion context matcher. Accepted forms are:

  • [+]AND_MATCHER: the expansion matches AND_MATCHER

  • -AND_MATCHER: the expansion does not match AND_MATCHER

  • [+]AND_MATCHER||EXP_MATCHER: either the expansion matches AND_MATCHER or it matches EXP_MATCHER

  • -AND_MATCHER||EXP_MATCHER: the expansion does not match AND_MATCHER but does match EXP_MATCHER

EXP_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER||EXP_MATCHER: either the expansion matches BASIC_MATCHER or it matches EXP_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EXP_MATCHER): the expansion matches EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • left_right(REGEX1,REGEX2): the tokens preceding and following the expansion matches, respectively, ^REGEX1$ and ^REGEX2$

  • context(STMT_MATCHER): the expansion is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • single_token(): the expansion is a single token

  • single_expr(): the expansion is a single expression

  • part_of_larger_expr(): the expansion is part of a larger expression

  • pp_expr(PP_MATCHER): the expansion is a preprocessor expression matching PP_EXP_MATCHER

PP_EXP_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the preprocessor expansion matches AND_MATCHER

  • -AND_MATCHER: the preprocessor expansion does not match AND_MATCHER

  • [+]AND_MATCHER||PP_EXP_MATCHER: either the preprocessor expansion matches AND_MATCHER or it matches PP_EXP_MATCHER

  • -AND_MATCHER||PP_EXP_MATCHER: the preprocessor expansion does not match AND_MATCHER but does match PP_EXP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the expansion matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PP_EXP_MATCHER): the expansion matches PP_EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • node(PP_ASTF[||PP_ASTF]*): the expansion’s representation matches one of the preprocessor AST functors

  • operator(PP_OPERATOR[||PP_OPERATOR]*): the expansion’s representation has a main operator that matches one of the preprocessor AST operators

PP_ASTF

accepted forms are:

  • binop: the expansion is a binary operator

  • unnop: the expansion is a unary operator (this includes the defined operator)

  • condop: the expansion is a conditional operator

  • pparen: the expansion is a parenthesized expression

  • pconst: the expansion is a constant value

PP_OPERATOR

accepted forms are:

  • comma: , comma operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • eq: == equality operator

  • ne: != inequality operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • add: + addition operator

  • sub: - subtraction operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • defined: defined operator


Rule B.MACROS

Summary

Macro expansions are shown.

Description

Each selected macro definition is shown if:

  • it is unused;

  • it expands to a sequence of tokens starting and ending on edges of AST nodes (any declarations, expressions, statements or types), with the expanded text;

  • it expands to a sequence of tokens in a preprocessor condition, with the expanded text;

Notes:

  • by default, all macros are checked and, for each expansion text, one sample is shown;

  • the macros and the maximum number of samples to be shown for any code resulting from the expansion of a selected macro can be specified using the macro_expansion service configuration;

  • the preferred samples that are shown can be changed using the sample_reports service configuration.

For example, the following configure line indicates that only function-like macros should be reported and that one sample for each expanded value should be shown:

-doc="Show only function like macros with one sample for each identical expansion."
-config=B.MACROS,macro_expansion={"function_like()", 1}

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=B.MACROS,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option macro_expansion
macro_expansion
-config=B.MACROS,macro_expansion={MACRO, MAX},...

Specify macro selectors with sample size for expansions that have the same text.

The configuration’s content is macro selectors with sample size for expansions that have the same text.

MACRO:

a -macro_selector identifier or a matcher expression used to select the macros.

MAX:

unlimited or the maximum number of samples to be shown.


Rule B.MONOINDENT

Summary

Use a monotonic indentation style.

Configuration

See generic service options.

Option indent_size
indent_size
-config=B.MONOINDENT,indent_size=SIZE

Specify size of indentation.

SIZE:

the number of spaces per indentation level. It must be an integer greater than or equal to 0.

Default:

-config=B.MONOINDENT,indent_size=1

Rule B.NAMING

Summary

Service for cloning by bespoke naming rules.

Description

The service enforces bespoke naming conventions for entities and macros.

Consider the following example:

-fmt={err_msg, enttname__default_fmt, "the identifier for %{node} is non-compliant"}

-doc_begin="Naming conventions for functions."
-clone_service=B.NAMING,Naming_Function
-config=Naming_Function,summary=
"Function names shall have a prefix congruent with the module name"
-config=Naming_Function,misnamed_entity_fmt+=
{hide,"kind(function)&&any_decl(loc(file(^.*_MOD1\.(h|c)$)))", "^MOD1_[a-zA-Z0-9]*$",""}
-config=Naming_Function,misnamed_entity_fmt+=
{hide,"kind(function)&&any_decl(loc(file(^.*_MOD2\.(h|c)$)))", "^MOD2_[a-zA-Z0-9]*$",""}
-config=Naming_Function,misnamed_entity_fmt+=
{show,"kind(function)", "^.*$",err_msg}
-doc_end

-doc_begin="Naming conventions for macros."
-clone_service=B.NAMING,Naming_Macro
-config=Naming_Macro,summary=
"Macro names shall be in uppercase with a prefix congruent with the module name"
-config=Naming_Macro,misnamed_macro_fmt=
{hide,"loc(file(^.*_MOD1\.(h|c)$))", "^MOD1_[A-Z0-9]*$",macro,""}
-config=Naming_Macro,misnamed_macro_fmt+=
{hide,"loc(file(^.*_MOD2\.(h|c)$))", "^MOD2_[A-Z0-9]*$",macro,""}
-config=Naming_Macro,misnamed_macro_fmt+=
{show,"any()", "^.*$",macro,err_msg}
-doc_end

The above configuration enforces the following naming rules:

  • function names shall have an uppercase prefix specifying the module name (e.g., “MOD1_fun()”);

  • macro names shall be preceded by the module prefix and has also to be declared in uppercase.

In our example, the source filenames follow the naming convention prefix_ModuleName.suffix (e.g., filename_MOD1.c). Making this assumption the module name can be inferred from the filename.

The misnamed_entity_fmt has been configured to check that the functions names follow the first rule, where the name of the module is taken from the filename.

Each module requires its own configuration: the first regular expression detects the entity to check, while the second checks the name of the function. If the function name is compatible with the file name no reports will be shown, otherwise the last row of the configuration will cause the reporting of the wrongly named function.

The last argument of the misnamed_macro_fmt (err_msg) can be used to provide a customizable error message (see the -fmt global configuration).

Entities and macros are treated differently by ECLAIR, for this reason two different configurations are required. misnamed_macro_fmt follows the same logics of misnamed_entity_fmt.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=B.NAMING,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=B.NAMING,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=B.NAMING,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=B.NAMING,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=B.NAMING,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=B.NAMING,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=B.NAMING,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule B.NARROWING

Summary

Narrowing integral to integral and pointer to integral casts are shown.

Configuration

See generic service options.

Rule B.ONESIDE

Summary

Except for function calls whose return value is stored, there should be no more than one side effect per expression.

Description

Reports:

  • An expression that has more than one side effect other than a function call whose return value is stored;

  • any expression whose value is ignored and has no side effects.Notes:

    • the side effect must be caused by the external operator/functor of the expression (and not just an effect of its sub-expressions);

    • explicit cast to void is not reported (see the corresponding Rule 2.2 on page 41 of MISRA C:2012 [45] ).

Configuration

See generic service options.

Option effects
effects
-config=B.ONESIDE,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule B.OVRDFINL

Summary

Override of virtual methods should use override or final keyword.

Configuration

See generic service options.

Rule B.PREPCMNT

Summary

Preprocessor directives ifdef, ifndef and if should be closed with an endif that is commented by the guard.

Configuration

See generic service options.

Rule B.PRSRDGNS

Summary

Code shall not generate a clang diagnostic message.

Description

Reports parser diagnostic messages that yield show according to the the diagnostics service configuration.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=B.PRSRDGNS,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule B.PTRDECL

Summary

Do not declare entities using pointer types.

Description

An entity is reported if either:

  • it has a type involving pointers; or

  • it is a function whose return type involves pointers.

Configuration

See generic service options.

Option declarations
declarations
-config=B.PTRDECL,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule B.PTRUSE

Summary

Do not refer to entities having a type that uses pointer types.

Description

An expression is reported if it refers to an entity whose type involves pointers.

Configuration

See generic service options.

Option declarations
declarations
-config=B.PTRUSE,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule B.RECUMACR

Summary

A program should not contain recursive macro invocations.

Configuration

See generic service options.

Rule B.REDCAST

Summary

A program should not contain redundant casts.

Description

Reports any use of redundant casts. A redundant cast is a superfluous cast, where the source and destination types are the same.

Configuration

See generic service options.

Option casts
casts
-config=B.REDCAST,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule B.REQMAN

Summary

Reports traceability of defined requirements.

Description

Here we just describe the main features of ECLAIR’s support for this service. For more information about how this may be integrated into a complete requirements management system see ECLAIR Requirements Management.

The service relies on a number of configuration parameters that define the project’s requirements and how code constructs relate (by means of special comments) to these requirements.

A requirement is a functionality of the software and its coverages are those aspects that directly relate to the code constructs and therefore are amenable to automatic checking.

The requirements are specified using the -requirements global configuration; this associates a requirement set identifier with a set of named requirements and a set of coverages. The coverages are specified using the -requirement_coverages global configuration that associates each coverage with a coverage tag and a (possibly empty) set of constraints.

The actual sets of requirements and coverages that are of interest to (a subset of) the project are specified by the -coverage_target service configuration.

A requirement comment is a comment that contains a coverage tag followed by a requirement identifier (extracted from the source code using the replacer specified by the -requirement_replacer service configuration).

A code construct is any declaration, statement or macro that matches a declaration, statement or macro matcher, specified by the -covering_construct service configuration. It can be associated to a requirement specification by means of one or more preceding comments (i.e., any comment before the code line with no intervening code or preprocessor lines).

ECLAIR will report a violation when a mismatch or an unexpected association is found between the configuration, comments and code constructs. For instance, when:

  • a selected code construct has no preceding comment;

  • a requirement comment does not precede a selected code construct;

  • a selected code construct has no associated requirement comment;

  • a requirement comment has unexpected text between requirement tags (i.e., something that is not a defined requirement identifier);

  • a requirement comment contains a duplicate requirement identifier;

  • the requirement coverage matcher from the -covering_construct service configuration used to select the construct does not match the requirement identifier and coverage tag in the associated requirement comment;

  • there is an inconsistency between requirements associated to selected code constructs for the same entity (e.g. the declaration(s) and the definition of a function).

Information reports are output for each valid requirement comment and its associated code construct.

Example:

The following configuration for -requirements associates the requirement set identifier impl_req to requirements {REQX, REQY} with coverage {IMPLEMENT} and the set identifier test_req to the requirement {REQZ} with coverages {IMPLEMENT, TEST}:

-requirements+={impl_req, {REQX, REQY}, {IMPLEMENT}}
-requirements+={test_req, {REQZ}, {IMPLEMENT, TEST}}

The following configuration for -requirement_coverages global configuration associates each coverage IMPLEMENT to the tag implements and TEST to the tag tests (note that, in both cases, the set of constraints is empty):

-requirement_coverages+={IMPLEMENT, "implements", {}}
-requirement_coverages+={TEST, "tests", {}}

The following configuration for -coverage_target service configuration indicates that code in all source files whose main source file is main.c must cover all the requirements in the requirement set impl_req for coverage IMPLEMENT:

-config=B.REQMAN,coverage_target={"main(^main\\.c$)", "set(impl_req)&&cov(IMPLEMENT)"}

The following configuration for the -covering_construct service configuration indicates that each function declaration (except for main()) should have a preceding comment that contains a requirement identifier in the set impl_req with coverage IMPLEMENT (and hence tag @implements or \implements):

-config=B.REQMAN,covering_construct={decl,
   "-^main(.*)$||kind(function)", "set(impl_req)&&cov(IMPLEMENT)"}

The acceptable forms of the requirement comment and how the requirements are extracted is specified using the -requirement_replacer service configuration. While it is possible to customize the extraction process, two templates called doxygen_comment and doxygen_line_comment that support the use of the coverage tags implements, tests and satisfies are available at "install_dir"/share/config/recipes/REQMAN.ecl see (Coverages). The following configuration lines will support the use of this replacer:

-eval_file=""install_dir"/share/config/recipes/REQMAN.ecl"
-config=B.REQMAN,requirement_replacer+=doxygen_comment

Then assuming the project contains the file main.c:

/**
 * @implements REQX, REQY
 */
int f() {...}

this replacer will extract the tag implements and requirements REQX and REQY. Then ECLAIR, using all the example’s configuration lines shown above, will deduce that the coverage IMPLEMENT for the requirements REQX and REQY is covered by the function f().

Configuration

See generic service options.

Option coverage_target
coverage_target
-config=B.REQMAN,coverage_target={FRAME_MATCHER, REQCOV_MATCHER},...

Specify the analysis frames and the associated requirement coverage matchers that define the requirements and coverages that need to be fulfilled by the matched frames.

The configuration’s content is a frame matcher with requirement coverage matcher.

FRAME_MATCHER:

a frame matcher. Accepted forms are:

  • [+]AND_MATCHER: the frame matches AND_MATCHER

  • -AND_MATCHER: the frame does not match AND_MATCHER

  • [+]AND_MATCHER||FRAME_MATCHER: either the frame matches AND_MATCHER or it matches FRAME_MATCHER

  • -AND_MATCHER||FRAME_MATCHER: the frame does not match AND_MATCHER but does match FRAME_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the frame matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the frame matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (FRAME_MATCHER): the frame matches FRAME_MATCHER

  • !BASIC_MATCHER: the frame does not match BASIC_MATCHER

  • any(): any frame matches

  • none(): no frame matches

  • target(FILE_MATCHER): the target file matches FILE_MATCHER (see the -file_tag global configuration)

  • main(FILE_MATCHER): the main file matches FILE_MATCHER (see the -file_tag global configuration)

  • kind(FRAME_KIND[||FRAME_KIND]*): the frame has one of the kind FRAME_KINDs

  • std(STD_MATCHER): the unit frame has a standard that matches STD_MATCHER (see the -stds global configuration)

FRAME_KIND

accepted forms are:

  • unit: unit analysis frame

  • program: program analysis frame

  • project: project analysis frame

  • object: object analysis frame

REQCOV_MATCHER:

a requirement-coverage matcher. Accepted forms are:

  • [+]AND_MATCHER: the requirement-coverage matches AND_MATCHER

  • -AND_MATCHER: the requirement-coverage does not match AND_MATCHER

  • [+]AND_MATCHER||REQCOV_MATCHER: either the requirement-coverage matches AND_MATCHER or it matches REQCOV_MATCHER

  • -AND_MATCHER||REQCOV_MATCHER: the requirement-coverage does not match AND_MATCHER but does match REQCOV_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the requirement-coverage matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the requirement-coverage matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (REQCOV_MATCHER): the requirement-coverage matches REQCOV_MATCHER

  • !BASIC_MATCHER: the requirement-coverage does not match BASIC_MATCHER

  • any(): any requirement-coverage matches

  • none(): no requirement-coverage matches

  • set(SET[||SET]*): the requirement set matches one of SET

  • req(REQ[||REQ]*): the requirement matches one of REQ

  • cov(COV[||COV]*): the requirement coverage matches one of COV

  • regex: a regex matching SET/REQ/COV, where SET is a regular expression matching requirement sets (see the -requirements global configuration), REQ is a regular expression matching requirement identifiers and COV is a regular expression matching coverage identifiers (see the -requirement_coverages global configuration)

REGEX

accepted forms are:


Option requirement_replacer
requirement_replacer
-config=B.REQMAN,requirement_replacer=ID,...

Specify the replacer that will extract a requirement tag and a requirement identifier from a comment (this extracted pair is referred to here as a tagged requirement).

The configuration’s content is a set of replacers to extract tagged requirements.

ID:

a replacer that matches the entire comment string (allowing for any whitespace characters) and extracts the tagged requirements; to save the tags for checking, use save(@0,A) where A specifies an extracted tagged requirement.


Option covering_construct
covering_construct
-config=B.REQMAN,covering_construct={KIND, NODE_MATCHER, REQCOV_MATCHER},...

Specify the constructs that should have a comment tagged with a requirement identifier.

The configuration’s content is a list of matcher kinds with a matcher to select constructs that should have comments with tagged requirements.

KIND:

matcher kind. Accepted values are:

  • decl: constructs are declarations and the MATCHER is a -decl_selector identifier or a matcher expression used to select the declarations;

  • stmt: constructs are statements and the MATCHER is a -stmt_selector identifier or a matcher expression used to select the statements or the expressions;

  • macro: constructs are macros and the MATCHER is a -macro_selector identifier or a matcher expression used to select the macro;

NODE_MATCHER:

a declaration, statement or macro matcher expression used to select the matching constructs (see the -decl_selector, the -stmt_selector and the -macro_selector global configurations).

REQCOV_MATCHER:

a requirement-coverage matcher. Accepted forms are:

  • [+]AND_MATCHER: the requirement-coverage matches AND_MATCHER

  • -AND_MATCHER: the requirement-coverage does not match AND_MATCHER

  • [+]AND_MATCHER||REQCOV_MATCHER: either the requirement-coverage matches AND_MATCHER or it matches REQCOV_MATCHER

  • -AND_MATCHER||REQCOV_MATCHER: the requirement-coverage does not match AND_MATCHER but does match REQCOV_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the requirement-coverage matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the requirement-coverage matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (REQCOV_MATCHER): the requirement-coverage matches REQCOV_MATCHER

  • !BASIC_MATCHER: the requirement-coverage does not match BASIC_MATCHER

  • any(): any requirement-coverage matches

  • none(): no requirement-coverage matches

  • set(SET[||SET]*): the requirement set matches one of SET

  • req(REQ[||REQ]*): the requirement matches one of REQ

  • cov(COV[||COV]*): the requirement coverage matches one of COV

  • regex: a regex matching SET/REQ/COV, where SET is a regular expression matching requirement sets (see the -requirements global configuration), REQ is a regular expression matching requirement identifiers and COV is a regular expression matching coverage identifiers (see the -requirement_coverages global configuration)

REGEX

accepted forms are:


Option comments
comments
-config=B.REQMAN,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=B.REQMAN,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule B.SOURCE_RANGE

Summary

Source range pseudo-checker.

Configuration

See generic service options.

Rule B.STATINIT

Summary

Static storage declarations should have a complete initializer.

Configuration

See generic service options.

Option declarations
declarations
-config=B.STATINIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option zero_init
zero_init
-config=B.STATINIT,zero_init=COND,...

Special conditions for zero initialization.

{COND,…}:

conditions for zero initialization, if set is empty, then there are no conditions for zero-initialization. Accepted members are:

  • top_level: zero initialization must be at the top-level;

  • explicit_init: zero initialization must be explicit;

  • no_cast: zero initialization must be without cast;

  • null_to_pointer: zero initialization may have a null_to_pointer cast;

Default:

-config=B.STATINIT,zero_init={}

Rule B.STRNVCBL

Summary

The vocabulary used in string literals should be precisely defined in a way that is amenable to automatic checking.

Description

Reports if string literals use vocabulary not in the dictionaries. See vocabulary for more information about the vocabulary dictionaries and their use

Configuration

See generic service options.

Option statements
statements
-config=B.STRNVCBL,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option project_dictionary
project_dictionary
-config=B.STRNVCBL,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=B.STRNVCBL,project_dictionary=""

Option context_dictionary
context_dictionary
-config=B.STRNVCBL,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=B.STRNVCBL,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=B.STRNVCBL,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=B.STRNVCBL,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=B.STRNVCBL,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=B.STRNVCBL,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=B.STRNVCBL,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=B.STRNVCBL,max_no_case_length=16

Option good_words_file
good_words_file
-config=B.STRNVCBL,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=B.STRNVCBL,good_words_file=""

Option bad_words_file
bad_words_file
-config=B.STRNVCBL,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=B.STRNVCBL,bad_words_file=""

Option good_items_file
good_items_file
-config=B.STRNVCBL,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=B.STRNVCBL,good_items_file=""

Option bad_items_file
bad_items_file
-config=B.STRNVCBL,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=B.STRNVCBL,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=B.STRNVCBL,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=B.STRNVCBL,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=B.STRNVCBL,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=B.STRNVCBL,bad_item_regexs={}

Option string_splitter
string_splitter
-config=B.STRNVCBL,string_splitter=SPLITTER,...

A list of regular expressions defining string literal splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:


Option contexts
contexts
-config=B.STRNVCBL,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule B.SYSTEM_REFERENCE

Summary

System code referenced by user is shown.

Configuration

See generic service options.

Rule B.TIE

Summary

Sample rule for service combining.

Configuration

See generic service options.

Option services
services
-config=B.TIE,services={TAG, SERVICE_MATCHER},...

Specifies the services to be suppressed.

The configuration’s content is a short-circuit sequence clause for suppressing services.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

SERVICE_MATCHER:

an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration).


Rule B.TROJANSOURCE

Summary

Source code shall not contain underhanded UTF-8 characters.

Description

Reports underhanded UTF-8 characters in source code.

Configuration

See generic service options.

Rule B.UNEVALEFF

Summary

The operand of the sizeof, alignof and typeof operators shall not contain any expression which has potential side effects.

Configuration

See generic service options.

Option effects
effects
-config=B.UNEVALEFF,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule B.UNUSED

Summary

Pseudo-checker for unuslocl and unusproj servants.

Configuration

See generic service options.

Option declarations
declarations
-config=B.UNUSED,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=B.UNUSED,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule B.UNUSLABL

Summary

Each label statement must be used either in a direct goto statement or its address must be taken and there is an indirect goto statement.

Configuration

See generic service options.

Option statements
statements
-config=B.UNUSLABL,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


The BUGSENG Tools

Tool B.CALLGRPH_DOT

Summary

Export callgrph edges to a representation that can be rendered with graphviz.

Description

Export callgrph edges to a representation that can be rendered with graphviz.

Configuration

See generic service options.

Option output_dot
output_dot
-config=B.CALLGRPH_DOT,output_dot=OUTPUT

The output file: for outputting the generated graph in dot format.

OUTPUT:

output file name.

Default:

-config=B.CALLGRPH_DOT,output_dot=/dev/stdout

Tool B.CBT

Summary

Tag reports using ECLAIR style comments.

Description

ECLAIR comment-based reports tagger.

Configuration

See generic service options.

Option remap
remap
-config=B.CBT,remap={FROM, TO},...

Specifies the remapping between comment content and ECLAIR services for suppression comments.

The configuration’s content is a list of pairs for remaps to be done.

FROM:

the content to be hidden as written in the comment.

TO:

a -service_selector identifier or a matcher expression used to select services whose report should be suppressed.

Default:

-config=B.CBT,remap={}

Tool B.CERTRAN

Summary

Collect build data for the automatic generation of compiler validation configurations.

Description

Note

This service is part of the cerTran product, which is separately licensed.

Configuration

See generic service options.

Option sort_options
sort_options
-config=B.CERTRAN,sort_options=sort_options

Whether options can be reordered.

sort_options:

whether options can be reordered. Accepted values are:

  • true: true;

  • false: false;

Default:

-config=B.CERTRAN,sort_options=true

Option ignored_options
ignored_options
-config=B.CERTRAN,ignored_options=OPTION_MATCHER,...

Specify the options that should be ignored.

The configuration’s content is a list of options matchers.

OPTION_MATCHER:

a -option_selector identifier or a matcher expression used to select the options.


Tool B.ECL

Summary

Reports unused ECL configurations.

Configuration

See generic service options.

Option configs
configs
-config=B.ECL,configs={CONFIG, ROW},...

Specify configuration explanations to be shown.

The configuration’s content is a set of configuration rows to be shown.

CONFIG:

config matcher. Accepted forms are:

  • [+]AND_MATCHER: the config matches AND_MATCHER

  • -AND_MATCHER: the config does not match AND_MATCHER

  • [+]AND_MATCHER||CONFIG_MATCHER: either the config matches AND_MATCHER or it matches CONFIG_MATCHER

  • -AND_MATCHER||CONFIG_MATCHER: the config does not match AND_MATCHER but does match CONFIG_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONFIG_MATCHER): the config matches CONFIG_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config matches

  • none(): no config matches

  • ^REGEX$: the config name matches ^REGEX$

  • any_row(ROW_MATCHER): the config has a row that matches ROW_MATCHER

  • all_row(ROW_MATCHER): all the config rows match ROW_MATCHER

  • kind(ID): the config kind is ID

  • service(SERVICE_MATCHER): the config whose service is matching SERVICE_MATCHER (see the -service_selector global configuration)

  • tracked(): the config is tracked

REGEX

accepted forms are:

ROW:

config row matches. Accepted forms are:

  • [+]AND_MATCHER: the config row matches AND_MATCHER

  • -AND_MATCHER: the config row does not match AND_MATCHER

  • [+]AND_MATCHER||ROW_MATCHER: either the config row matches AND_MATCHER or it matches ROW_MATCHER

  • -AND_MATCHER||ROW_MATCHER: the config row does not match AND_MATCHER but does match ROW_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config row matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ROW_MATCHER): the config row matches ROW_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config row matches

  • none(): no config row matches

  • ^REGEX$: the config name matches ^REGEX$

  • user(): the config row is a user row

  • used(): the config row is used

REGEX

accepted forms are:

Default:

-config=B.ECL,configs={"tracked()", "!used()&&user()"}

Tool B.EXPLAIN

Summary

Explain user configuration.

Configuration

See generic service options.

Option configs
configs
-config=B.EXPLAIN,configs={CONFIG, ROW},...

Specify configuration explanations to be shown.

The configuration’s content is a set of configuration rows to be shown.

CONFIG:

config matcher. Accepted forms are:

  • [+]AND_MATCHER: the config matches AND_MATCHER

  • -AND_MATCHER: the config does not match AND_MATCHER

  • [+]AND_MATCHER||CONFIG_MATCHER: either the config matches AND_MATCHER or it matches CONFIG_MATCHER

  • -AND_MATCHER||CONFIG_MATCHER: the config does not match AND_MATCHER but does match CONFIG_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONFIG_MATCHER): the config matches CONFIG_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config matches

  • none(): no config matches

  • ^REGEX$: the config name matches ^REGEX$

  • any_row(ROW_MATCHER): the config has a row that matches ROW_MATCHER

  • all_row(ROW_MATCHER): all the config rows match ROW_MATCHER

  • kind(ID): the config kind is ID

  • service(SERVICE_MATCHER): the config whose service is matching SERVICE_MATCHER (see the -service_selector global configuration)

  • tracked(): the config is tracked

REGEX

accepted forms are:

ROW:

config row matches. Accepted forms are:

  • [+]AND_MATCHER: the config row matches AND_MATCHER

  • -AND_MATCHER: the config row does not match AND_MATCHER

  • [+]AND_MATCHER||ROW_MATCHER: either the config row matches AND_MATCHER or it matches ROW_MATCHER

  • -AND_MATCHER||ROW_MATCHER: the config row does not match AND_MATCHER but does match ROW_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config row matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ROW_MATCHER): the config row matches ROW_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config row matches

  • none(): no config row matches

  • ^REGEX$: the config name matches ^REGEX$

  • user(): the config row is a user row

  • used(): the config row is used

REGEX

accepted forms are:

Default:

-config=B.EXPLAIN,configs={"any()", "user()"}

Option ecl
ecl
-config=B.EXPLAIN,ecl=TAG

Specify if ECL commands should be shown.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

Default:

-config=B.EXPLAIN,ecl=show

Tool B.EXPLAIN_ECL

Summary

Report explained configuration attached to related ECL commands.

Configuration

See generic service options.

Option configs
configs
-config=B.EXPLAIN_ECL,configs={CONFIG, ROW},...

Specify configuration explanations to be shown.

The configuration’s content is a set of configuration rows to be shown.

CONFIG:

config matcher. Accepted forms are:

  • [+]AND_MATCHER: the config matches AND_MATCHER

  • -AND_MATCHER: the config does not match AND_MATCHER

  • [+]AND_MATCHER||CONFIG_MATCHER: either the config matches AND_MATCHER or it matches CONFIG_MATCHER

  • -AND_MATCHER||CONFIG_MATCHER: the config does not match AND_MATCHER but does match CONFIG_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONFIG_MATCHER): the config matches CONFIG_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config matches

  • none(): no config matches

  • ^REGEX$: the config name matches ^REGEX$

  • any_row(ROW_MATCHER): the config has a row that matches ROW_MATCHER

  • all_row(ROW_MATCHER): all the config rows match ROW_MATCHER

  • kind(ID): the config kind is ID

  • service(SERVICE_MATCHER): the config whose service is matching SERVICE_MATCHER (see the -service_selector global configuration)

  • tracked(): the config is tracked

REGEX

accepted forms are:

ROW:

config row matches. Accepted forms are:

  • [+]AND_MATCHER: the config row matches AND_MATCHER

  • -AND_MATCHER: the config row does not match AND_MATCHER

  • [+]AND_MATCHER||ROW_MATCHER: either the config row matches AND_MATCHER or it matches ROW_MATCHER

  • -AND_MATCHER||ROW_MATCHER: the config row does not match AND_MATCHER but does match ROW_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config row matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ROW_MATCHER): the config row matches ROW_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config row matches

  • none(): no config row matches

  • ^REGEX$: the config name matches ^REGEX$

  • user(): the config row is a user row

  • used(): the config row is used

REGEX

accepted forms are:

Default:

-config=B.EXPLAIN_ECL,configs={"kind(ordered)&&(any_row(user())||tracked()&&any_row(used()))", "any()"}, {"tracked()", "used()||user()"}, {"service(enabled)||service(none())", "any()"}, {"any()", "user()"}

Tool B.EXPLAIN_FULL

Summary

Explain used configuration.

Configuration

See generic service options.

Option configs
configs
-config=B.EXPLAIN_FULL,configs={CONFIG, ROW},...

Specify configuration explanations to be shown.

The configuration’s content is a set of configuration rows to be shown.

CONFIG:

config matcher. Accepted forms are:

  • [+]AND_MATCHER: the config matches AND_MATCHER

  • -AND_MATCHER: the config does not match AND_MATCHER

  • [+]AND_MATCHER||CONFIG_MATCHER: either the config matches AND_MATCHER or it matches CONFIG_MATCHER

  • -AND_MATCHER||CONFIG_MATCHER: the config does not match AND_MATCHER but does match CONFIG_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONFIG_MATCHER): the config matches CONFIG_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config matches

  • none(): no config matches

  • ^REGEX$: the config name matches ^REGEX$

  • any_row(ROW_MATCHER): the config has a row that matches ROW_MATCHER

  • all_row(ROW_MATCHER): all the config rows match ROW_MATCHER

  • kind(ID): the config kind is ID

  • service(SERVICE_MATCHER): the config whose service is matching SERVICE_MATCHER (see the -service_selector global configuration)

  • tracked(): the config is tracked

REGEX

accepted forms are:

ROW:

config row matches. Accepted forms are:

  • [+]AND_MATCHER: the config row matches AND_MATCHER

  • -AND_MATCHER: the config row does not match AND_MATCHER

  • [+]AND_MATCHER||ROW_MATCHER: either the config row matches AND_MATCHER or it matches ROW_MATCHER

  • -AND_MATCHER||ROW_MATCHER: the config row does not match AND_MATCHER but does match ROW_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the config row matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the config matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ROW_MATCHER): the config row matches ROW_MATCHER

  • !BASIC_MATCHER: the config does not match BASIC_MATCHER

  • any(): any config row matches

  • none(): no config row matches

  • ^REGEX$: the config name matches ^REGEX$

  • user(): the config row is a user row

  • used(): the config row is used

REGEX

accepted forms are:

Default:

-config=B.EXPLAIN_FULL,configs={"kind(ordered)&&(any_row(user())||tracked()&&any_row(used()))", "any()"}, {"tracked()", "used()||user()"}, {"service(enabled)||service(none())", "any()"}, {"any()", "user()"}

Option ecl
ecl
-config=B.EXPLAIN_FULL,ecl=TAG

Specify if ECL commands should be shown.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

Default:

-config=B.EXPLAIN_FULL,ecl=show

Tool B.FRAMES

Summary

Report analysis frames matching specific criteria.

Description

Given the expected command of a frame as a regex reports inconsistencies with the actual command given.

Configuration

See generic service options.

Option frame_select
frame_select
-config=B.FRAMES,frame_select={TAG, MATCHER, FMT},...

Specify frames to be shown using a short-circuit sequence.

The configuration’s content is a list of frame matchers with formats.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • error: show as error report if it matches the associated conditions;

  • caution: show as a caution report if it matches the associated conditions;

  • information: show as an information report if it matches the associated conditionsbugs will be reported as information;

  • violation: show as violation report if it matches the associated conditions;

MATCHER:

a -frame_selector identifier or a matcher expression used to select the frames.

FMT:

format (see the -fmt global configuration content, template frameslct__default_fmt).


Tool B.LINTCBT

Summary

Hide reports using lint style suppression comments.

Description

Interprets lint comment-based suppressions.

Configuration

See generic service options.

Option remap
remap
-config=B.LINTCBT,remap={FROM, TO},...

Specifies the remapping between comment content and ECLAIR services for suppression comments.

The configuration’s content is a list of pairs for remaps to be done.

FROM:

the content to be hidden as written in the comment.

TO:

a -service_selector identifier or a matcher expression used to select services whose report should be suppressed.

Default:

-config=B.LINTCBT,remap={}

Tool B.OBJCMP

Summary

Built object files should not differ from the reference ones.

Description

Built object files that differ from the reference ones are shown

It is crucial to realize the importance of this tool, especially in connection with the coding rules that many perceive it as simply cosmetic.

Consider, for instance, a rule insisting on the presence of parentheses.

Without B.OBJCOMP it is true that making an existing project compliant might introduce bugs; so, in that case, accepting non-compliance might be the wisest choice.

The situation is completely reversed when B.OBJCOMP is used to monitor the work done to bring the project into compliance.

Say we add a pair of parentheses; there are two cases:

  1. B.OBJCOMP reports nothing: we are sure we did not introduce a bug and we increased readability, something that will pay off in the future;

  2. B.OBJCOMP reports object code changes; looking carefully at what we did, we will discover either:

    • we added parentheses in the wrong positions: no problem, we move them to the right positions;

    • we added parentheses in the right positions; that is, we discovered a genuine bug in our project and we can now fix it.

Implementation

The build is tracked and complete information about the produced object files is saved into NEW_DIR (see the new_dir service configuration).

If OLD_DIR (see the old_dir service configuration) exists and contains information about a certain object file that is different from the newly generated information, then the compilation producing that object is shown.

A new reference point can be created by the user at any time by copying or renaming NEW_DIR to OLD_DIR (e.g., by rd /s /q OLD_DIR followed by xcopy NEW_DIR OLD_DIR /s or rename NEW_DIR OLD_DIR, on Windows; by rm -rf NEW_DIR followed by cp -R OLD_DIR NEW_DIR or mv OLD_DIR NEW_DIR, on Linux and macOS).

Configuration

See generic service options.

Option old_dir
old_dir
-config=B.OBJCMP,old_dir=OLD_DIR

Specify where the information on old objects is stored.

OLD_DIR:

pathname of the directory containing old objects.

Default:

-config=B.OBJCMP,old_dir=/tmp/old

Option new_dir
new_dir
-config=B.OBJCMP,new_dir=NEW_DIR

Specify where to store information on the new objects.

NEW_DIR:

pathname of the directory where to store new objects.

Default:

-config=B.OBJCMP,new_dir=/tmp/new

Tool B.OBJTOUCH

Summary

Objects produced by the build are touched.

Description

Each object file produced by the tracked build is touched, i.e., its access and modification times are set to the current time.

Configuration

See generic service options.

Tool B.PRQACBT

Summary

Hide reports using PRQA style suppression comments.

Description

Interprets PRQA comment-based suppressions.

Configuration

See generic service options.

Option remap
remap
-config=B.PRQACBT,remap={FROM, TO},...

Specifies the remapping between comment content and ECLAIR services for suppression comments.

The configuration’s content is a list of pairs for remaps to be done.

FROM:

the content to be hidden as written in the comment.

TO:

a -service_selector identifier or a matcher expression used to select services whose report should be suppressed.

Default:

-config=B.PRQACBT,remap={}

Tool B.PSOFTCBT

Summary

Hide reports using parasoft style suppression comments.

Description

Interprets parasoft comment-based suppressions.

Configuration

See generic service options.

Option remap
remap
-config=B.PSOFTCBT,remap={FROM, TO},...

Specifies the remapping between comment content and ECLAIR services for suppression comments.

The configuration’s content is a list of pairs for remaps to be done.

FROM:

the content to be hidden as written in the comment.

TO:

a -service_selector identifier or a matcher expression used to select services whose report should be suppressed.

Default:

-config=B.PSOFTCBT,remap={}

Tool B.SCOUT

Summary

All callable entities that are possibly reachable from program entry points are shown.

Description

For general information about this tool and some illustrative examples, see ECLAIR Code Scout.

Configuration

See generic service options.

Option output_entity_selector
output_entity_selector
-config=B.SCOUT,output_entity_selector=selector_name

Specify an entity selector identifier to be used to generate an -entity_selector for reachable entities.

selector_name:

an identifier used to create a named -entity_selector for reachable entities.

Default:

-config=B.SCOUT,output_entity_selector=reachable

Option declarations
declarations
-config=B.SCOUT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=B.SCOUT,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Option output_ecl
output_ecl
-config=B.SCOUT,output_ecl=OUTPUT

The output file: for outputting the generated ecl.

OUTPUT:

output file name.


Tool B.TEXTFIND

Summary

Show the source text matching the specified regular expressions.

Description

The source text matching the specified matcher will be shown

Configuration

See generic service options.

Option text_matcher
text_matcher
-config=B.TEXTFIND,text_matcher={ID, REGEX, ACTIONS},...

Associate a text matcher identifier to a regular expression with the reporting actions for each matched text.

The configuration’s content is a collection of named text matchers, a regular expression and reporting actions.

ID:

a text matcher identifier.

REGEX:

a regular expression; captured groups can be referred in the actions using the groups’ indices.

ACTIONS:

a sequence of actions to be applied to the matched texts. Accepted forms are:

  • MATCHER_ACTION[;MATCHER_ACTION]*: perform the sequence of actions MATCHER_ACTION;... to the matched texts

MATCHER_ACTION

accepted forms are:

  • if(COND_MATCHER,ACTION1[,ACTION2]): if the condition specified by COND_MATCHER holds, then do action ACTION1 else do action ACTION2

  • shift(ID): change the text matcher to ID

  • REPORT_KIND(AREA[,AREA]*): create a report of kind REPORT_KIND with the specified areas

  • ID(REGEX_GROUP): secondary text matcher ID to be applied to the text selected by the captured group REGEX_GROUP

COND_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the condition matches AND_MATCHER

  • -AND_MATCHER: the condition does not match AND_MATCHER

  • [+]AND_MATCHER||COND_MATCHER: either the conditions matches AND_MATCHER or it matches COND_MATCHER

  • -AND_MATCHER||COND_MATCHER: the type does not match AND_MATCHER but does match COND_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the condition matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the condition matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COND_MATCHER): the condition matches COND_MATCHER

  • !BASIC_MATCHER: the condition does not match BASIC_MATCHER

  • [REGEX_GROUP]REGEX: the condition holds if the text selected by captured group REGEX_GROUP is matched by REGEX

AREA

accepted forms are:

  • AREA_KIND(REGEX_GROUP,FMT): report area of kind AREA_KIND located at the text selected by the captured group REGEX_GROUP with message formatted by FMT (see the -fmt global configuration content, template textfind__default_fmt) with fields:

group0

the whole matched expression;

groupN

the N-th matched group of the regular expression, where N must be less than or equal to 10.

AREA_KIND

accepted forms are:

  • culprit: culprit area

  • evidence: evidence area

  • context: context area

REPORT_KIND

accepted forms are:

  • violation: violation report

  • caution: caution report

  • information: information report

REGEX_GROUP

accepted forms are:

  • NUM: matched group number

REGEX

accepted forms are:

Default:

-config=B.TEXTFIND,text_matcher={eol_whitespace, "[ \\t]+(?=[\\r\\n\\f])", "violation(culprit(0,eol_whitespace_fmt))"}, {non_ascii, "[^\\f\\n\\r\\t -~]", "violation(culprit(0,non_ascii_fmt))"}

Option match
match
-config=B.TEXTFIND,match=ID,...

List of matchers to be applied to source files.

The configuration’s content is a list of text matchers to apply.

ID:

a text matcher identifier (see the text_matcher service configuration.


Tool B.TGEN

Summary

Automatic unit-test generator.

Configuration

See generic service options.

Coverage Criteria

Parameters in this section allow the specification of the coverage criteria to be used for testcase generation. Code coverage criteria specify which program entities, such as statements, branches and decisions, should be exercised. Operator coverage criteria specify cases (usually associated to some anomalous behavior) associated to specific semantic operators; for instance, the generation of testcases resulting into an integer divide by zero can be requested.

Option code_coverage
code_coverage
-config=B.TGEN,code_coverage=COVER

Specify the code coverage criterion for testcase generation.

COVER:

choose the code coverage criterion. Accepted values are:

  • none: no code coverage;

  • statement: statement coverage;

  • branch: branch coverage;

Default:

-config=B.TGEN,code_coverage=none

Option operator_coverage
operator_coverage
-config=B.TGEN,operator_coverage={TAG, OP_SET},...

Specifies the operator coverage criterion for testcase generation.

The configuration’s content is a short-circuit sequence with operator special case set names.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

OP_SET:

a FIXME.

Default:

-config=B.TGEN,operator_coverage={}

Option operator_special
operator_special
-config=B.TGEN,operator_special={NAMED, {{{OP_SET,...}, CASE, DESC},...}},...

Specifies named operator special case sets to be used in the definition of the operator coverage criterion.

The configuration’s content is a FIXME.

NAMED:

a FIXME.

{OP_SET,…}:

a set of operators. Accepted members are:

  • add_floating: floating-point add;

  • add_signed: signed integer add;

  • add_unsigned: unsigned integer add;

  • and_signed: signed bitwise and;

  • div_floating: floating-point div;

  • div_signed: signed integer div;

  • div_unsigned: unsigned integer div;

  • floating_cast: a FIXME;

  • unsafe_floating_cast: a FIXME;

  • floating_to_signed: a FIXME;

  • floating_to_unsigned: a FIXME;

  • signed_to_floating: a FIXME;

  • unsigned_to_floating: a FIXME;

  • minus_signed: signed integer unary minus;

  • minus_unsigned: unsigned integer unary minus;

  • mul_floating: floating-point mul;

  • mul_signed: signed integer mul;

  • mul_unsigned: unsigned integer mul;

  • not_signed: a FIXME;

  • or_signed: a FIXME;

  • rem_signed: a FIXME;

  • rem_unsigned: a FIXME;

  • shl_signed: signed shift left;

  • shl_unsigned: unsigned shift left;

  • shr_signed: signed shift right;

  • signed_to_larger_unsigned: a FIXME;

  • signed_to_same_unsigned: a FIXME;

  • signed_to_shift_rhs: a FIXME;

  • signed_to_smaller_signed: a FIXME;

  • signed_to_smaller_unsigned: a FIXME;

  • sub_floating: a FIXME;

  • sub_signed: a FIXME;

  • sub_unsigned: a FIXME;

  • to_bitfield_signed: a FIXME;

  • to_bitfield_unsigned: a FIXME;

  • unsigned_to_same_signed: a FIXME;

  • unsigned_to_shift_rhs: a FIXME;

  • unsigned_to_smaller_signed: a FIXME;

  • unsigned_to_smaller_unsigned: a FIXME;

  • xor_signed: signed bitwise xor;

  • libm_floating: libm floating-point functions;

CASE:

a case in the definition of the semantics of an operator. Accepted values are:

  • normal: a FIXME;

  • bitwise_on_neg: a FIXME;

  • by_zero: a FIXME;

  • inexact: a FIXME;

  • min_by_minus_one: a FIXME;

  • neq_floored_div: a FIXME;

  • neg_lhs: a FIXME;

  • neg_overflow: a FIXME;

  • pos_overflow: a FIXME;

  • finite_to_minf: a FIXME;

  • finite_to_pinf: a FIXME;

  • num_to_nan: a FIXME;

  • bad_gamma_argument: a FIXME;

  • illcond_trig_argument: a FIXME;

DESC:

a FIXME.


Option prove
prove
-config=B.TGEN,prove=CONDS

Specifies whether proof of the #ECLAIR_prove conditions should be attempted (by attempting coverage of their negations).

CONDS:

a FIXME. Accepted values are:

  • false: a FIXME;

  • true: a FIXME;

Default:

-config=B.TGEN,prove=false

Unfolding and Unrolling

Parameters in this section provide ways to control the unfolding of function calls and unrolling of program loops. Note: These parameters reflect some limitations in the current implementation of the tool and should be considered as experimental.

Option loop_iterations
loop_iterations
-config=B.TGEN,loop_iterations=LOOP_IT

Maximum number of loop iterations to be followed.

LOOP_IT:

a FIXME. It must be an integer greater than or equal to 1.

Default:

-config=B.TGEN,loop_iterations=1

Program Semantics

Parameters in this section allow a very fine-grain control of the semantics of the program. The semantics of each semantic operator can be selected from a number of alternatives; for instance, signed integer division can be truncated (as mandated by C99) or floored (as allowed by C90). The semantics of accesses to undefined variables can also be selected as well as all the aspects involved in the use of floating-point quantities.

Option operator_semantics
operator_semantics
-config=B.TGEN,operator_semantics={{OP_SET,...}, CASE, BEHAVIOR},...

FIXME.

The configuration’s content is a FIXME.

{OP_SET,…}:

a set of operators. Accepted members are:

  • add_floating: floating-point add;

  • add_signed: signed integer add;

  • add_unsigned: unsigned integer add;

  • and_signed: signed bitwise and;

  • div_floating: floating-point div;

  • div_signed: signed integer div;

  • div_unsigned: unsigned integer div;

  • floating_cast: a FIXME;

  • unsafe_floating_cast: a FIXME;

  • floating_to_signed: a FIXME;

  • floating_to_unsigned: a FIXME;

  • signed_to_floating: a FIXME;

  • unsigned_to_floating: a FIXME;

  • minus_signed: signed integer unary minus;

  • minus_unsigned: unsigned integer unary minus;

  • mul_floating: floating-point mul;

  • mul_signed: signed integer mul;

  • mul_unsigned: unsigned integer mul;

  • not_signed: a FIXME;

  • or_signed: a FIXME;

  • rem_signed: a FIXME;

  • rem_unsigned: a FIXME;

  • shl_signed: signed shift left;

  • shl_unsigned: unsigned shift left;

  • shr_signed: signed shift right;

  • signed_to_larger_unsigned: a FIXME;

  • signed_to_same_unsigned: a FIXME;

  • signed_to_shift_rhs: a FIXME;

  • signed_to_smaller_signed: a FIXME;

  • signed_to_smaller_unsigned: a FIXME;

  • sub_floating: a FIXME;

  • sub_signed: a FIXME;

  • sub_unsigned: a FIXME;

  • to_bitfield_signed: a FIXME;

  • to_bitfield_unsigned: a FIXME;

  • unsigned_to_same_signed: a FIXME;

  • unsigned_to_shift_rhs: a FIXME;

  • unsigned_to_smaller_signed: a FIXME;

  • unsigned_to_smaller_unsigned: a FIXME;

  • xor_signed: signed bitwise xor;

  • libm_floating: libm floating-point functions;

CASE:

a case in the definition of the semantics of an operator. Accepted values are:

  • normal: a FIXME;

  • bitwise_on_neg: a FIXME;

  • by_zero: a FIXME;

  • inexact: a FIXME;

  • min_by_minus_one: a FIXME;

  • neq_floored_div: a FIXME;

  • neg_lhs: a FIXME;

  • neg_overflow: a FIXME;

  • pos_overflow: a FIXME;

  • finite_to_minf: a FIXME;

  • finite_to_pinf: a FIXME;

  • num_to_nan: a FIXME;

  • bad_gamma_argument: a FIXME;

  • illcond_trig_argument: a FIXME;

BEHAVIOR:

a behavior in the definition of the semantics of an operator. Accepted values are:

  • arith: a FIXME;

  • ieee754: a FIXME;

  • logical: a FIXME;

  • floored: a FIXME;

  • round_current: a FIXME;

  • round_down: a FIXME;

  • round_near: a FIXME;

  • round_up: a FIXME;

  • round_zero: a FIXME;

  • trimmed: a FIXME;

  • unspecified: a FIXME;

  • wrapping: a FIXME;

Default:

-config=B.TGEN,operator_semantics={}

Option uninitialized_behavior
uninitialized_behavior
-config=B.TGEN,uninitialized_behavior=VSEM

Specifies the semantics to be applied to uninitialized variables.

VSEM:

a FIXME. Accepted values are:

  • trimmed: a FIXME;

  • unspecified: a FIXME;

Default:

-config=B.TGEN,uninitialized_behavior=trimmed

Option default_rounding
default_rounding
-config=B.TGEN,default_rounding=RMODE

Specifies the default rounding mode for floating-point operations.

RMODE:

a FIXME. Accepted values are:

  • near: a FIXME;

  • up: a FIXME;

  • down: a FIXME;

  • zero: a FIXME;

Default:

-config=B.TGEN,default_rounding=near

Option nan_in_floats
nan_in_floats
-config=B.TGEN,nan_in_floats=NAN

Specifies whether NaNs are allowed in floating-point quantities.

NAN:

a FIXME. Accepted values are:

  • false: a FIXME;

  • true: a FIXME;

Default:

-config=B.TGEN,nan_in_floats=true

Option minf_in_floats
minf_in_floats
-config=B.TGEN,minf_in_floats=NINF

Specifies whether -inf is allowed in floating-point quantities.

NINF:

a FIXME. Accepted values are:

  • false: a FIXME;

  • true: a FIXME;

Default:

-config=B.TGEN,minf_in_floats=true

Option pinf_in_floats
pinf_in_floats
-config=B.TGEN,pinf_in_floats=PINF

Specifies whether +inf is allowed in floating-point quantities.

PINF:

a FIXME. Accepted values are:

  • false: a FIXME;

  • true: a FIXME;

Default:

-config=B.TGEN,pinf_in_floats=true

Option sub_in_floats
sub_in_floats
-config=B.TGEN,sub_in_floats=PINF

Specifies whether subnormals are allowed in floating-point quantities.

PINF:

a FIXME. Accepted values are:

  • false: a FIXME;

  • true: a FIXME;

Default:

-config=B.TGEN,sub_in_floats=true

Limits to Constraint Resolution

Parameters in this section allow controlling the constraint resolution process in order to limit the amount of resources it is allowed to consume.

Option labeling_limit
labeling_limit
-config=B.TGEN,labeling_limit=LAB_LIMIT

An integer encoding a limit to be applied to the labeling phase of constraint resolution: the higher the value the higher the running time, the lower the chances of getting a “don’t know”.

LAB_LIMIT:

a FIXME. It must be an integer greater than or equal to 1.

Default:

-config=B.TGEN,labeling_limit=100

Option propagation_limit
propagation_limit
-config=B.TGEN,propagation_limit=PROP_LIMIT

An integer encoding a limit to be applied to the propagation phase of constraint resolution: the higher the value the higher the running time, the lower the chances of getting a “don’t know”.

PROP_LIMIT:

a FIXME. It must be an integer greater than or equal to 1.

Default:

-config=B.TGEN,propagation_limit=100

Option dlr_limit
dlr_limit
-config=B.TGEN,dlr_limit=DLR_LIMIT

An integer encoding a limit to be applied to the dynamic linear relaxation phase of constraint resolution: the higher the value the higher the running time, the lower the chances of getting a “don’t know”.

DLR_LIMIT:

a FIXME. It must be an integer greater than or equal to 1.

Default:

-config=B.TGEN,dlr_limit=1000000000

Debugging and Self-Testing

Parameters in this section are related to debugging and self-testing of the testcase generator. They are only relevant to developers and to those who want to assess the capabilities of the tool.

Option trace
trace
-config=B.TGEN,trace=TBEHAVIOR

Specifies the tracing behavior of the servant.

TBEHAVIOR:

a FIXME. Accepted values are:

  • none: a FIXME;

  • novalues: a FIXME;

  • values: a FIXME;

Default:

-config=B.TGEN,trace=values

Option test_program_file
test_program_file
-config=B.TGEN,test_program_file=FNAME

An output file where the self-test program is written.

FNAME:

a FIXME.

Default:

-config=B.TGEN,test_program_file=""

Tool B.TOOLCHAIN

Summary

ECLAIR shall be able to retrieve toolchain information from the toolchain itself.

Description

Reports any failure to retrieve toolchain information from the toolchain itself. If this cannot be achieved (e.g., because the toolchain is missing or is not working with the given command-line options), ECLAIR skips the corresponding analysis, which may result into incorrect and/or incomplete analysis results

Configuration

See generic service options.

Tool B.UNREACH

Summary

Unreachable functions in a program, given a set of entry points, are shown.

Description

Checker for definitely unreachable functions given a set of entry points

Configuration

See generic service options.

Option declarations
declarations
-config=B.UNREACH,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=B.UNREACH,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


The CERT C Secure Coding Standard rules, second edition

For the CERT-C-2014 coding standard [28], each of the supported guidelines, the identifier for the corresponding ECLAIR service is obtained by adding the prefix CC2, thereby obtaining, for example: CC2.ARR36, CC2.DCL30, CC2.EXP39, …

Note that the page numbers included in the references to [28] in the ECLAIR service summaries are for the PDF version of [28] .

Rule CC2.ARR36

Summary

Do not subtract or compare two pointers that do not refer to the same array. (See page 217 of CERT-C-2014 [28] .)

Description

If one pointer is subtracted from or compared with another pointer, then both the pointers must point to elements in the same array.

Configuration

See generic service options.

Rule CC2.ARR37

Summary

Do not add or subtract an integer to a pointer to a non-array object. (See page 229 of CERT-C-2014 [28] .)

Description

If an integer is added to or subtracted from a pointer, then that pointer must point to an array or an array element.

Configuration

See generic service options.

Rule CC2.DCL30

Summary

Declare objects with appropriate storage durations. (See page 57 of CERT-C-2014 [28] .)

Description

An object with automatic storage must not have its address:

  • assigned to another automatic object of larger scope; or

  • assigned to a static object; or

  • returned by a function.

Note that only objects with automatic storage duration are checked; that is, there is no checking of objects with thread or allocated storage duration.

Configuration

See generic service options.

Rule CC2.DCL31

Summary

Declare identifiers before using them. (See page 61 of CERT-C-2014 [28] .)

Description

Checks that:

  • a function declaration or definition has a function prototype;

  • a function is declared with a prototype declaration or definition before any reference to it;

  • the type of any parameter or object declaration is explicitly stated;

  • the type of the return value of any function declaration or definition must be explicitly stated;

  • the type of any typedef declaration is explicitly stated.

Configuration

See generic service options.

Option declarations
declarations
-config=CC2.DCL31,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option statements
statements
-config=CC2.DCL31,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CC2.DCL31,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CC2.DCL36

Summary

Do not declare an identifier with conflicting linkage classifications. (See page 65 of CERT-C-2014 [28] .)

Description

Any variable or function declaration or definition with internal linkage must include the storage class specifier static.

Configuration

See generic service options.

Option declarations
declarations
-config=CC2.DCL36,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CC2.DCL37

Summary

Do not declare or define a reserved identifier. (See page 68 of CERT-C-2014 [28] .)

Description

No #define or #undef directive may be used on a reserved identifier, macro or function in the standard library.

The reserved identifiers are defined to include all the following:

  • identifiers that are reserved by the C11 standard [40];

  • identifiers that are reserved by the standard used by the translation unit;

  • identifiers reserved for future library directions.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=CC2.DCL37,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=CC2.DCL37,reserved_standard="std()"

Option declarations
declarations
-config=CC2.DCL37,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=CC2.DCL37,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=CC2.DCL37,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CC2.DCL38

Summary

Use the correct syntax when declaring flexible array members. (See page 74 of CERT-C-2014 [28] .)

Description

A struct whose last field has an array type with 0 or 1 elements is reported.

Configuration

See generic service options.

Option declarations
declarations
-config=CC2.DCL38,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CC2.DCL39

Summary

Avoid information leakage in structure padding. (See page 77 of CERT-C-2014 [28] .)

Description

Local storage variable must not have a type that is a padding struct, union or class.

Configuration

See generic service options.

Rule CC2.DCL40

Summary

Do not create incompatible declarations of the same function or object. (See page 82 of CERT-C-2014 [28] .)

Description

Checks that:

  • if a variable is declared more than once, the types are compatible;

  • if a function has more than one prototype declaration or definition, the corresponding parameter types or return types are compatible.

External identifiers (including macro names) differ in their first 31 characters both before and after any macro expansion.

Configuration

See generic service options.

Option declarations
declarations
-config=CC2.DCL40,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option identifier_length
identifier_length
-config=CC2.DCL40,identifier_length={SEL, CASE, LEN},...

Specify significant length and case significance for identifiers for selected entities.

The configuration’s content is a list of entity matchers with significant length and case significance.

SEL:

a -entity_selector identifier or a matcher expression used to select the entities.

CASE:

indicate if case is significant. Accepted values are:

  • case_insensitive: case is not significant;

  • case_sensitive: case is significant;

LEN:

length of significant leading part of identifier; 0 indicates that there is no limit. It must be an integer greater than or equal to 0.

Default:

-config=CC2.DCL40,identifier_length={external_identifiers, case_sensitive, 31}

Option ignored_decls
ignored_decls
-config=CC2.DCL40,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=CC2.DCL40,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CC2.DCL41

Summary

Do not declare variables inside a switch statement before the first case label. (See page 88 of CERT-C-2014 [28] .)

Description

A switch statement body must begin with a case or default label.

Configuration

See generic service options.

Option terminals
terminals
-config=CC2.DCL41,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=CC2.DCL41,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=CC2.DCL41,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule CC2.ENV33

Summary

Do not call system(). (See page 364 of CERT-C-2014 [28] .)

Description

There must be no use of the standard library function system provided by stdlib.h.

Configuration

See generic service options.

Option declarations
declarations
-config=CC2.ENV33,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CC2.EXP30

Summary

Do not depend on order of evaluation for side-effects. (See page 93 of CERT-C-2014 [28] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule CC2.EXP32

Summary

Do not access a volatile object through a non-volatile reference. (See page 99 of CERT-C-2014 [28] .)

Description

A volatile object must not be accessed through a non-volatile object.

Configuration

See generic service options.

Option casts
casts
-config=CC2.EXP32,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CC2.EXP33

Summary

Do not read uninitialized memory. (See page 101 of CERT-C-2014 [28] .)

Description

All automatic variables must have a value written to them before being read.

Note that this does not necessarily require initialization at the declaration.

Note also that initializing any one member of a union is not considered as (proper) initialization of the other members.

Implementation

Reports if an automatic variable may be used without initialization.

Imprecision

Cautions are reported when the analyzer cannot determine the necessary execution order.

Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}

Since realloc can change the size of an object, any use of the standard library functions that return an uninitialized heap is reported as a caution.

Configuration

See generic service options.

Option member_areas
member_areas
-config=CC2.EXP33,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=CC2.EXP33,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=CC2.EXP33,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CC2.EXP34

Summary

Do not dereference null pointers. (See page 110 of CERT-C-2014 [28] .)

Description

Null pointers must not be de-referenced.

Configuration

See generic service options.

Rule CC2.EXP35

Summary

Do not modify objects with temporary lifetime. (See page 115 of CERT-C-2014 [28] .)

Description

A dot member expression must be an lvalue.

Configuration

See generic service options.

Option statements
statements
-config=CC2.EXP35,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CC2.EXP35,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CC2.EXP36

Summary

Do not cast pointers into more strictly aligned pointer types. (See page 118 of CERT-C-2014 [28] .)

Description

A pointer type must not be cast to a more strictly aligned pointer type.

Configuration

See generic service options.

Option casts
casts
-config=CC2.EXP36,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CC2.EXP37

Summary

Call functions with the correct number and type of arguments. (See page 122 of CERT-C-2014 [28] .)

Description

Checks that:

  • any call to a function has an explicit protoype declaration;

  • the number of arguments passed to the function match the number of parameters;

  • the type of each argument is compatible with the declared type of the parameter;

  • if the parameter type is a pointer, then the pointee type of the argument is compatible with the pointee type of the parameter;

  • calls to type-generic functions in <math.h> that expect real values do not have complex-valued arguments.

Configuration

See generic service options.

Option calls
calls
-config=CC2.EXP37,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=CC2.EXP37,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option casts
casts
-config=CC2.EXP37,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option contexts
contexts
-config=CC2.EXP37,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CC2.EXP39

Summary

Do not access a variable through a pointer of an incompatible type. (See page 128 of CERT-C-2014 [28] .)

Description

A pointer should not be cast to a different type (excluding qualifiers).

Any such casts, implicit or explicit, will be reported as a caution.

Configuration

See generic service options.

Option casts
casts
-config=CC2.EXP39,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CC2.EXP40

Summary

Do not modify constant values. (See page 134 of CERT-C-2014 [28] .)

Description

A pointer to a type with a const qualifier should not be cast to a pointer to a type without the qualifier.

Any such casts, implicit or explicit, will be reported as a caution.

Configuration

See generic service options.

Option casts
casts
-config=CC2.EXP40,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CC2.EXP42

Summary

Do not compare padding data. (See page 136 of CERT-C-2014 [28] .)

Description

There must be no calls to memcmp with arguments whose pointees are padding records.

Configuration

See generic service options.

Option calls
calls
-config=CC2.EXP42,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CC2.EXP44

Summary

Do not rely on side effects in operands to sizeof, _Alignof, or _Generic. (See page 147 of CERT-C-2014 [28] .)

Description

Expressions with side effects must not be used in operands for calls to the sizeof, _Alignof, or _Generic operators.

Configuration

See generic service options.

Option effects
effects
-config=CC2.EXP44,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule CC2.EXP45

Summary

Do not perform assignments in selection statements. (See page 150 of CERT-C-2014 [28] .)

Description

Any expression with a simple or compound assignment operator must not be used in one of the following ways:

  • as an operand of &&, ||;

  • in the condition part of the :? operator;

  • in the condition part of an if, do, for, or while statement;

  • as the right-hand side operand of a comma expression, when this comma expression is used in any of the other contexts.

Configuration

See generic service options.

Option statements
statements
-config=CC2.EXP45,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CC2.EXP45,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CC2.FIO41

Summary

Do not call getc(), putc(), getwc(), or putwc() with a stream argument that has side effects. (See page 329 of CERT-C-2014 [28] .)

Description

Expressions with side effects must not be used in stream arguments for calls to the getc, putc, getwc, putwc input/output functions.

Configuration

See generic service options.

Option effects
effects
-config=CC2.FIO41,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule CC2.FIO47

Summary

Use valid format strings. (See page 344 of CERT-C-2014 [28] .)

Description

The input/output functions must use formatting strings that are valid and compatible with the rest of the functions’ arguments.

Configuration

See generic service options.

Rule CC2.FLP30

Summary

Do not use floating point variables as loop counters. (See page 197 of CERT-C-2014 [28] .)

Configuration

See generic service options.

Option for_counter
for_counter
-config=CC2.FLP30,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Rule CC2.INT34

Summary

Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand. (See page 183 of CERT-C-2014 [28] .)

Description

The value of the right-hand operand of a shift operator must lie between zero and one less than the width in bits of the underlying type of the left-hand operand.

Source code expressions and preprocessor conditional expressions are checked.

Where the values are unknown, a caution is output.

Imprecision

Cautions are reported for non-constant values on the right-hand side of a shift operator.

Configuration

See generic service options.

Rule CC2.INT36

Summary

Converting a pointer to integer or integer to pointer. (See page 190 of CERT-C-2014 [28] .)

Description

A pointer type must not be cast to an integer type and an integer type must not be cast to a pointer type.

Explicit casts from integral constants to pointers are permitted to allow addressing of hardware memory mapped areas.

Configuration

See generic service options.

Option casts
casts
-config=CC2.INT36,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CC2.MSC30

Summary

Do not use the rand() function for generating pseudorandom numbers. (See page 481 of CERT-C-2014 [28] .)

Description

There must be no use of the standard library function rand.

Configuration

See generic service options.

Option declarations
declarations
-config=CC2.MSC30,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CC2.MSC37

Summary

Ensure that control never reaches the end of a non-void function. (See page 491 of CERT-C-2014 [28] .)

Description

Any non-void function definition must not have:

  • a return statement with an empty expression;

  • any exit path that does not terminate with a return statement.

An allowed exception is the main function.

Configuration

See generic service options.

Option statements
statements
-config=CC2.MSC37,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CC2.MSC37,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=CC2.MSC37,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule CC2.PRE30

Summary

Do not create a universal character name through concatenation. (See page 47 of CERT-C-2014 [28] .)

Description

A universal character name must not be created by means of concatenation.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CC2.PRE30,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CC2.PRE31

Summary

Avoid side-effects in arguments to unsafe macros. (See page 48 of CERT-C-2014 [28] .)

Description

Checks that:

  • if an argument in an invocation of a function-like macro expands to an expression that contains a side effect, then the corresponding parameter occurs no more than once in the macro body;

  • if an (unexpanded) argument in an invocation of a function-like macro has an assignment, increment or decrement operator, then the corresponding parameter occurs at least once in the macro body.

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CC2.PRE31,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CC2.PRE31,macro_argument_context={}

Option macros
macros
-config=CC2.PRE31,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CC2.PRE32

Summary

Do not use preprocessor directives in invocations of function-like macros. (See page 53 of CERT-C-2014 [28] .)

Description

Function-like macros must not include preprocessor directives.

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CC2.PRE32,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CC2.PRE32,macro_argument_context={}

Option macros
macros
-config=CC2.PRE32,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CC2.STR30

Summary

Do not attempt to modify string literals. (See page 247 of CERT-C-2014 [28] .)

Description

String literals must not be modified.

Configuration

See generic service options.

Rule CC2.STR34

Summary

Cast characters to unsigned char before converting to larger integer sizes. (See page 268 of CERT-C-2014 [28] .)

Description

Signed character data (and plain character data where plain char is defined to have the same representation as signed char) must be converted to unsigned char before being assigned or converted to a larger signed type.

Configuration

See generic service options.

Rule CC2.STR37

Summary

Arguments to character-handling functions must be representable as an unsigned char. (See page 272 of CERT-C-2014 [28] .)

Description

If the plain char type is defined to have the same representation as signed char, then the arguments to character handling functions must be representable as an unsigned char.

Configuration

See generic service options.

Option calls
calls
-config=CC2.STR37,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option macro_argument_context
macro_argument_context
-config=CC2.STR37,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CC2.STR37,macro_argument_context={}

Option macros
macros
-config=CC2.STR37,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CC2.STR38

Summary

Do not confuse narrow and wide character strings and functions. (See page 274 of CERT-C-2014 [28] .)

Description

Narrow string arguments must not be passed to wide string functions and wide string arguments must not be passed to narrow string functions.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CC2.STR38,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


The CERT C Secure Coding Standard recommendations

Rule CCR.API08

Summary

Protect header prototypes from misinterpretation. (See https://www.securecoding.cert.org/confluence/display/seccode/API08-C.+Protect+header+prototypes+from+misinterpretation .)

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.API08,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.ARR02

Summary

Explicitly specify array bounds, even if implicitly defined by an initializer. (See https://www.securecoding.cert.org/confluence/display/seccode/ARR02-C.+Explicitly+specify+array+bounds%2C+even+if++implicitly+defined+by+an+initializer .)

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.ARR02,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.DCL00

Summary

Const-qualify immutable objects. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL00-C.+Const-qualify+immutable+objects .)

Description

In the declarations of variables, use const wherever possible.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=CCR.DCL00,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=CCR.DCL00,show_declarations=all

Option single_assign
single_assign
-config=CCR.DCL00,single_assign=BOOL

Specify if an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const.

BOOL:

boolean. Accepted values are:

  • true: an uninitialized local variable declaration with a single assignment will be considered for converting the constness to const;

  • false: an uninitialized local variable declaration with a single assignment will not be considered for converting the constness to const;

Default:

-config=CCR.DCL00,single_assign=true

Option declarations
declarations
-config=CCR.DCL00,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=CCR.DCL00,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=CCR.DCL00,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule CCR.DCL01

Summary

Do not reuse variable names in subscopes. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL01-C.+Do+not+reuse+variable+names+in+subscopes .)

Configuration

See generic service options.

Rule CCR.DCL02

Summary

Use visually distinct identifiers. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL02-C.+Use+visually+distinct+identifiers .)

Description

The first 31 characters of any identifier (including macro and macro parameter names) must be unique (compared to all other identifiers visible in its scope) after applying the following ordered list of replacements:

  • replace 0 by O,

  • replace D by O,

  • replace 1 by I,

  • replace l by I,

  • replace 5 by S,

  • replace 2 by Z,

  • replace 8 by B,

  • replace rn by m,

  • replace h by n.

Configuration

See generic service options.

Option similar_map
similar_map
-config=CCR.DCL02,similar_map={MATCH_ID, MAPPING},...

Specify mappings of identifiers to their canonical form.

The configuration’s content is a list of identifier mappings.

MATCH_ID:

the identifier for the selected entities.

MAPPING:

. Accepted forms are:

  • std(REGEX): matches a service

  • min(NUMBER,CASE): the identifier prefix of length NUMBER, (after convertion to upper-case, if CASE is case_insensitive), is the canonical form

  • REPLACER[||REPLACER]*): a list of alternative REPLACERs (see the -replacer global configuration) defining the replacements that map the identifier to its canonical forms

CASE

accepted forms are:

  • case_sensitive: the identifier is case-sensitive

  • case_insensitive: the identifier is case-insensitive and the canonical form has all letters converted to upper-case

Default:

-config=CCR.DCL02,similar_map={all_identifiers, "substr(0,31)|replace('rn','m')|tr('0D1l528h','OOIISZBn')"}

Option ignored_decls
ignored_decls
-config=CCR.DCL02,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=CCR.DCL02,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CCR.DCL03

Summary

Use a static assertion to test the value of a constant expression. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL03-C.+Use+a+static+assertion+to+test+the+value+of+a+constant+expression .)

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CCR.DCL03,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CCR.DCL03,macro_argument_context={}

Option macros
macros
-config=CCR.DCL03,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CCR.DCL04

Summary

Do not declare more than one variable per declaration. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL04-C.+Do+not+declare+more+than+one+variable+per+declaration .)

Description

Each variable declarator must be on a separate line have its own personal declaration.

Configuration

See generic service options.

Option contexts
contexts
-config=CCR.DCL04,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CCR.DCL06

Summary

Use meaningful symbolic constants to represent literal values. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL06-C.+Use+meaningful+symbolic+constants+to+represent+literal+values .)

Configuration

See generic service options.

Option literal_matches
literal_matches
-config=CCR.DCL06,literal_matches={TAG, {LIT_COND,...}},...

Specify what is a magic constant.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

LIT_COND:

literal condition. Accepted alternatives are:

  • {ancestors, CTXT}: .

    CTXT:

    a -context_selector identifier or a matcher expression used to select the contexts.

  • {exact_macro_expansion}: an exact macro expansion.

  • {paren_macro_expansion}: a parenthesized macro expansion.

  • {in_macro_body}: literal is in macro body.

  • {expanded_from_macro, MACRO_MATCHER}: expanded from matching macro.

    MACRO_MATCHER:

    a -macro_selector identifier or a matcher expression used to select the macros.

  • {text, TEXT_RE}: regular expression to match literal.

    TEXT_RE:

    constant text matcher.

  • {character_literal}: character literal.

  • {wide_char_literal}: wide char literal.

  • {utf16_char_literal}: utf16 char literal.

  • {utf32_char_literal}: utf32 char literal.

  • {floating_literal}: floating literal.

  • {integer_literal}: integer literal.

  • {string_literal}: string literal.

  • {wide_string_literal}: wide string literal.

  • {utf8_string_literal}: utf8 string literal.

  • {utf16_string_literal}: utf16 string literal.

  • {utf32_string_literal}: utf32 string literal.

Default:

-config=CCR.DCL06,literal_matches={hide, {{paren_macro_expansion}}}, {hide, {{integer_literal}, {text, "^(0|-?1|2)[LUlu]*$"}}}, {hide, {{character_literal}, {text, "^'.'$"}}}, {hide, {{string_literal}, {text, "^\".?\"$"}}}, {hide, {{ancestors, __indirect_init_contexts}}}

Option literal_kinds
literal_kinds
-config=CCR.DCL06,literal_kinds=LIT,...

Specify the kinds of literals to be checked.

{LIT,…}:

the literal families to be checked. Accepted members are:

  • floating_literal: floating literal;

  • integer_literal: integer literal;

  • character_literal: character literal;

  • string_literal: string literal;

  • ordinary: ordinary character or string literal;

  • wide: wide character or string literal;

  • utf16: utf16 character or string literal;

  • utf32: utf32 char literal;

  • utf8: utf8 string literal;

Default:

-config=CCR.DCL06,literal_kinds=character_literal, integer_literal, floating_literal, string_literal

Option literals
literals
-config=CCR.DCL06,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule CCR.DCL07

Summary

Include the appropriate type information in function declarators. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL07-C.+Include+the+appropriate+type+information+in+function+declarators .)

Description

Checks that:

  • the type of any parameter or object declaration is explicitly stated;

  • the type of the return value of any function declaration or definition is explicitly stated;

  • there are no K&R function declarations.

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.DCL07,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.DCL11

Summary

Understand the type issues associated with variadic functions. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL11-C.+Understand+the+type+issues+associated+with+variadic+functions .)

Configuration

See generic service options.

Rule CCR.DCL13

Summary

Declare function parameters that are pointers to values not changed by the function as const. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL13-C.+Declare+function+parameters+that+are+pointers+to+values+not+changed+by+the+function+as+const .)

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=CCR.DCL13,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=CCR.DCL13,show_declarations=all

Option declarations
declarations
-config=CCR.DCL13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=CCR.DCL13,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=CCR.DCL13,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule CCR.DCL15

Summary

Declare file-scope objects or functions that do not need external linkage as static. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL15-C.+Declare+file-scope+objects+or+functions+that+do+not+need+external+linkage+as+static .)

Description

A function or variable will be reported if all the following hold:

  • it has linkage;

  • it is referenced;

  • either all references to it are in the same function or, if it is a variable with external linkage, then all references are in the same unit;

  • it is not explicitly declared static.

Configuration

See generic service options.

Option definition_in_same_unit
definition_in_same_unit
-config=CCR.DCL15,definition_in_same_unit=BOOL

Specify if the definition must be in the same translation unit as the references.

BOOL

Accepted values are:

  • true: the definition must be in the same translation unit as the references;

  • false: the definition does not have to be in the same translation unit as the references;

Default:

-config=CCR.DCL15,definition_in_same_unit=true

Option declarations
declarations
-config=CCR.DCL15,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.DCL16

Summary

Use ‘L’, not ‘l’, to indicate a long value. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL16-C.+Use+%27L%27%2C+not+%27l%27%2C+to+indicate+a+long+value .)

Configuration

See generic service options.

Option literals
literals
-config=CCR.DCL16,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule CCR.DCL19

Summary

Minimize the scope of variables and functions. (See https://www.securecoding.cert.org/confluence/display/seccode/DCL19-C.+Minimize+the+scope+of+variables+and+functions .)

Description

Reports any variable for which one of the following holds:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • it is used in a single file but declared in a different file.

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.DCL19,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=CCR.DCL19,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule CCR.ERR01

Summary

Use ferror() rather than errno to check for FILE stream errors. (See https://www.securecoding.cert.org/confluence/display/seccode/ERR01-C.+Use+ferror%28%29+rather+than+errno+to+check+for+FILE+stream+errors .)

Configuration

See generic service options.

Option macros
macros
-config=CCR.ERR01,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=CCR.ERR01,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.EXP00

Summary

Use parentheses for precedence of operation. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP00-C.+Use+parentheses+for+precedence+of+operation .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=CCR.EXP00,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule CCR.EXP05

Summary

Do not cast away a const qualification. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP05-C.+Do+not+cast+away+a+const+qualification .)

Configuration

See generic service options.

Option casts
casts
-config=CCR.EXP05,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CCR.EXP06

Summary

Operands to the sizeof operator should not contain side effects. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP06-C.+Operands+to+the+sizeof+operator+should+not+contain+side+effects .)

Configuration

See generic service options.

Option effects
effects
-config=CCR.EXP06,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule CCR.EXP09

Summary

Use sizeof to determine the size of a type or variable. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP09-C.+Use+sizeof+to+determine+the+size+of+a+type+or+variable .)

Configuration

See generic service options.

Option calls
calls
-config=CCR.EXP09,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CCR.EXP12

Summary

Do not ignore values returned by functions. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP12-C.+Do+not+ignore+values+returned+by+functions .)

Description

Reports if the value returned by a non-void function is not used.

Notes:

  • calls to a non-void function whose return value is ignored are reported;

  • calls where the return value is cast to void are not individually reported as the explicit cast to void is taken to be a deviation request by the user.

  • all calls are included in a statistical summary for the program and the called function;

  • the summary provides:

    • the number of calls to the function,

    • the number of times the return value is ignored but this was expected,

    • the number of times the return value is cast to void and

    • the number of times it is ignored unexpectedly;

  • the number of samples shown can be changed using the use_samples service configuration.

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=CCR.EXP12,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option use_samples
use_samples
-config=CCR.EXP12,use_samples={TAG, MAX},...

Specify the maximum number of samples to be output.

The configuration’s content is a list of return use tags (ignored, to_void, used) with the maximum number of samples to be output; if a use tag is not specified, then all calls matching the tag will be shown as violations.

TAG:

tag indicating the return use. Accepted values are:

  • used: return value is used;

  • ignored: return value is ignored;

  • to_void: return value is cast to void;

MAX:

maximum number of samples to be shown. It must be an integer greater than or equal to -1.

Default:

-config=CCR.EXP12,use_samples={ignored, -1}, {to_void, 1}, {used, 1}

Option calls
calls
-config=CCR.EXP12,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=CCR.EXP12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.EXP13

Summary

Treat relational and equality operators as if they were nonassociative. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP13-C.+Treat+relational+and+equality+operators+as+if+they+were+nonassociative .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=CCR.EXP13,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule CCR.EXP18

Summary

Do not perform assignments in selection statements. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP18-C.+Do+not+perform+assignments+in+selection+statements .)

Configuration

See generic service options.

Option statements
statements
-config=CCR.EXP18,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CCR.EXP18,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CCR.EXP21

Summary

Place constants on the left of equality comparisons. (See https://www.securecoding.cert.org/confluence/display/seccode/EXP21-C.+Place+constants+on+the+left+of+equality+comparisons .)

Description

Reports when constants are not on the left of the equality == operator.

Configuration

See generic service options.

Option statements
statements
-config=CCR.EXP21,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CCR.EXP21,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CCR.FIO07

Summary

Prefer fseek() to rewind(). (See https://www.securecoding.cert.org/confluence/display/seccode/FIO07-C.+Prefer+fseek%28%29+to+rewind%28%29 .)

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.FIO07,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.FIO12

Summary

Prefer setvbuf() to setbuf(). (See https://www.securecoding.cert.org/confluence/display/seccode/FIO12-C.+Prefer+setvbuf%28%29+to+setbuf%28%29 .)

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.FIO12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.FLP00

Summary

Understand the limitations of floating point numbers. (See https://www.securecoding.cert.org/confluence/display/seccode/FLP00-C.+Understand+the+limitations+of+floating+point+numbers .)

Description

Floating-point expressions must not be tested for equality.

Exceptions

Note that comparison with 0.0 can be exempted using the statements service configuration.

Implementation

Floating-point expressions are non-compliant if they are used:

  1. as operands f1 and f2 in explicit equality and inequality comparisons f1 == f2 and f1 != f2;

  2. as arguments to boolean operators &&, || or !;

  3. as the conditions for if, for, do, and while statements;

  4. in indirect tests for equality for floating point expressions (f1 op1 f2) && (f3 op2 f4), where op1 and op2 are relational operators <=, >=, < or > and either op1 is the inverse of op2, the expressions f1 and f3 are equivalent, and the expressions f2, f4 are equivalent, or op1 and op2 are the same, the expressions f1, f4 are equivalent and the expressions f2, f3 are equivalent.

Note that in item 4, for this rule, expressions e1, e2 are taken to be equivalent, if, after dropping any parentheses and unary + operators:

  • they are the same variable or literal;

  • have the same operator and have equivalent arguments;

  • have the forms f1 op f2 and f3 op f4 where op is a non-assignment binary operator, the expressions f1, f3 are equivalent and the expressions f2, f4 are equivalent or op is one of the commuting operators + or * and the expressions f1, f4 are equivalent and the expressions f2, f3 are equivalent.

Imprecision

False negatives are present because recognising indirect equality and inequality tests is undecidable.

For example, the following function, depending on the definition of g() might or might not test the equality of x and y:

float* p;
int f(float x, float y) {
  if (x < y)
    return 0;
  *p = y;
  g();
  if (-*p < -y)
    return 0;
  return 1;
}

Said that, the rule captures most (if not all) reasonable ways in which a programmer in good-faith (i.e., not deliberately attempting to break the rule) might code an equality/inequality test on floating-point expressions.

Configuration

See generic service options.

Option statements
statements
-config=CCR.FLP00,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule CCR.INT02

Summary

Understand integer conversion rules. (See https://www.securecoding.cert.org/confluence/display/seccode/INT02-C.+Understand+integer+conversion+rules .)

Description

Reports:

  • implicit sign conversions for integral operands of arithmetic (and logical) operators;

  • implicit narrowing conversions for integral operands;

  • the use of unary - when the type of the operand is unsigned;

  • when the result of applying operators ~ and << to an operand having type unsigned char or unsigned short is not immediately cast back to the type of the operand.

Configuration

See generic service options.

Option etypes
etypes
-config=CCR.INT02,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule CCR.INT07

Summary

Use only explicitly signed or unsigned char type for numeric values. (See https://www.securecoding.cert.org/confluence/display/seccode/INT07-C.+Use+only+explicitly+signed+or+unsigned+char+type+for+numeric+values .)

Configuration

See generic service options.

Option calls
calls
-config=CCR.INT07,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CCR.INT09

Summary

Ensure enumeration constants map to unique values. (See https://www.securecoding.cert.org/confluence/display/seccode/INT09-C.+Ensure+enumeration+constants+map+to+unique+values .)

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.INT09,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.INT12

Summary

Do not make assumptions about the type of a plain int bit-field when used in an expression. (See https://www.securecoding.cert.org/confluence/display/seccode/INT12-C.+Do+not+make+assumptions+about+the+type+of+a+plain+int+bit-field+when+used+in+an+expression .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=CCR.INT12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=CCR.INT12,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule CCR.INT13

Summary

Use bitwise operators only on unsigned operands. (See https://www.securecoding.cert.org/confluence/display/seccode/INT13-C.+Use+bitwise+operators+only+on+unsigned+operands .)

Configuration

See generic service options.

Option statements
statements
-config=CCR.INT13,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CCR.INT13,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CCR.MEM02

Summary

Immediately cast the result of a memory allocation function call into a pointer to the allocated type. (See https://www.securecoding.cert.org/confluence/display/seccode/MEM02-C.+Immediately+cast+the+result+of+a+memory+allocation+function+call+into+a+pointer+to+the+allocated+type .)

Configuration

See generic service options.

Option calls
calls
-config=CCR.MEM02,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CCR.MEM08

Summary

Use realloc() only to resize dynamically allocated arrays. (See https://www.securecoding.cert.org/confluence/display/seccode/MEM08-C.+Use+realloc%28%29+only+to+resize+dynamically+allocated+arrays .)

Configuration

See generic service options.

Option calls
calls
-config=CCR.MEM08,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CCR.MSC00

Summary

Compile cleanly at high warning levels. (See https://www.securecoding.cert.org/confluence/display/seccode/MSC00-C.+Compile+cleanly+at+high+warning+levels .)

Configuration

See generic service options.

Option hidden_options
hidden_options
-config=CCR.MSC00,hidden_options={TAGS, TOOL, {OPTION_MATCHER,...}},...

Specify tags for command lines that match the option selectors.

The configuration’s content is list of tagged option matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TOOL:

tool kind. Accepted values are:

  • compiler: compiler tool;

  • linker: linker tool;

OPTION_MATCHER:

option matcher string. Accepted forms are:

  • ^REGEX$: option matches ^REGEX$

  • !OPTION_MATCHER: option does not match OPTION_MATCHER

  • ID: option matches one of the patterns listed in ecl variable ID (a name beginning with a letter)

  • TEXT: option matches string TEXT

REGEX

accepted forms are:


Rule CCR.MSC01

Summary

Strive for logical completeness. (See https://www.securecoding.cert.org/confluence/display/seccode/MSC01-C.+Strive+for+logical+completeness .)

Configuration

See generic service options.

Option else_empty
else_empty
-config=CCR.MSC01,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=CCR.MSC01,else_empty={missing, "none()"}, {null, "none()"}, {empty_compound, "any()"}

Option ignored_comments
ignored_comments
-config=CCR.MSC01,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option declarations
declarations
-config=CCR.MSC01,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CCR.MSC04

Summary

Use comments consistently and in a readable fashion. (See https://www.securecoding.cert.org/confluence/display/seccode/MSC04-C.+Use+comments+consistently+and+in+a+readable+fashion .)

Configuration

See generic service options.

Option comments
comments
-config=CCR.MSC04,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=CCR.MSC04,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=CCR.MSC04,code_lines=0

Option ignored_comments
ignored_comments
-config=CCR.MSC04,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=CCR.MSC04,ignored_comments=__doxygen_comments

Rule CCR.MSC05

Summary

Do not manipulate time_t typed values directly. (See https://www.securecoding.cert.org/confluence/display/seccode/MSC05-C.+Do+not+manipulate+time_t+typed+values+directly .)

Configuration

See generic service options.

Option statements
statements
-config=CCR.MSC05,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CCR.MSC05,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CCR.MSC12

Summary

Detect and remove code that has no effect. (See https://www.securecoding.cert.org/confluence/display/seccode/MSC12-C.+Detect+and+remove+code+that+has+no+effect .)

Configuration

See generic service options.

Rule CCR.MSC17

Summary

Finish every set of statements associated with a case label with a break statement. (See https://www.securecoding.cert.org/confluence/display/seccode/MSC17-C.+Finish+every+set+of+statements+associated+with+a+case+label+with+a+break+statement .)

Configuration

See generic service options.

Option terminals
terminals
-config=CCR.MSC17,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=CCR.MSC17,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=CCR.MSC17,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule CCR.MSC20

Summary

Do not use a switch statement to transfer control into a complex block. (See https://www.securecoding.cert.org/confluence/display/seccode/MSC20-C.+Do+not+use+a+switch+statement+to+transfer+control+into+a+complex+block .)

Configuration

See generic service options.

Option switch_clauses
switch_clauses
-config=CCR.MSC20,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=CCR.MSC20,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule CCR.PRE00

Summary

Prefer inline or static functions to function-like macros. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE00-C.+Prefer+inline+or+static+functions+to+function-like+macros .)

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CCR.PRE00,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CCR.PRE00,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=CCR.PRE00,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CCR.PRE01

Summary

Use parentheses within macros around parameter names. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE01-C.+Use+parentheses+within+macros+around+parameter+names .)

Configuration

See generic service options.

Option param_parentheses
param_parentheses
-config=CCR.PRE01,param_parentheses=CONDS,...

Specify conditions when parameter parentheses are not required.

The configuration’s content is a short-circuit sequence of macro parameter parentheses.

CONDS:

conditions for parameter parentheses. Accepted forms are:

  • binary_op(): the parameter is an argument to a binary operator

  • unary_op(): the parameter is an argument to a unary operator

  • conditional_op(): the parameter is an argument to a conditional operator

  • pre(PRE_POST_EXPR): the tokens before the parameter must match PRE_POST_EXPR

  • post(PRE_POST_EXPR): the tokens after the parameter must match PRE_POST_EXPR

  • pre_post(PRE_POST_EXPR0,PRE_POST_EXPR1): the tokens before the parameter must match PRE_POST_EXPR0 and the tokens after the parameter must match PRE_POST_EXPR1

PRE_POST_EXPR

accepted forms are:

  • QSTRING: quoted token sequence

  • QSTRING||PRE_POST_EXPR: alternative quoted token sequences

Default:

-config=CCR.PRE01,param_parentheses="pre('->'||'.')"

Option macros
macros
-config=CCR.PRE01,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CCR.PRE02

Summary

Macro replacement lists should be parenthesized. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE02-C.+Macro+replacement+lists+should+be+parenthesized .)

Configuration

See generic service options.

Option macros
macros
-config=CCR.PRE02,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CCR.PRE03

Summary

Prefer typedefs to defines for encoding types. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE03-C.+Prefer+typedefs+to+defines+for+encoding+types .)

Configuration

See generic service options.

Option macros
macros
-config=CCR.PRE03,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CCR.PRE04

Summary

Do not reuse a standard header file name. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE04-C.+Do+not+reuse+a+standard+header+file+name .)

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=CCR.PRE04,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=CCR.PRE04,reserved_standard="min(c99)"

Rule CCR.PRE06

Summary

Enclose header files in an inclusion guard. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE06-C.+Enclose+header+files+in+an+inclusion+guard .)

Configuration

See generic service options.

Option directives
directives
-config=CCR.PRE06,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule CCR.PRE07

Summary

Avoid using repeated question marks. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE07-C.+Avoid+using+repeated+question+marks .)

Configuration

See generic service options.

Rule CCR.PRE08

Summary

Guarantee that header file names are unique. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE08-C.+Guarantee+that+header+file+names+are+unique .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=CCR.PRE08,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=CCR.PRE08,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule CCR.PRE12

Summary

Do not define unsafe macros. (See https://www.securecoding.cert.org/confluence/display/seccode/PRE12-C.+Do+not+define+unsafe+macros .)

Configuration

See generic service options.

Option macros
macros
-config=CCR.PRE12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CCR.STR04

Summary

Use plain char for characters in the basic character set. (See https://www.securecoding.cert.org/confluence/display/seccode/STR04-C.+Use+plain+char+for+characters+in+the+basic+character+set .)

Configuration

See generic service options.

Rule CCR.STR05

Summary

Use pointers to const when referring to string literals. (See https://www.securecoding.cert.org/confluence/display/seccode/STR05-C.+Use+pointers+to+const+when+referring+to+string+literals .)

Configuration

See generic service options.

Option same_pointee
same_pointee
-config=CCR.STR05,same_pointee=BOOL

Specify if the string literal and the pointer referring to the string literal must point to the same character type.

BOOL:

boolean. Accepted values are:

  • true: the string literal and the pointer referring to the string literal must point to the same character type;

  • false: the string literal and the pointer referring to the string literal do not have to point to the same type;

Default:

-config=CCR.STR05,same_pointee=false

Option ignored_stmts
ignored_stmts
-config=CCR.STR05,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule CCR.STR10

Summary

Do not concatenate different type of string literals. (See https://www.securecoding.cert.org/confluence/display/seccode/STR10-C.+Do+not+concatenate+different+type+of+string+literals .)

Configuration

See generic service options.

The CERT C++ Secure Coding Standard rules

Rule CP1.ARR02

Summary

Explicitly specify array bounds, even if implicitly defined by an initializer. (See https://www.securecoding.cert.org/confluence/display/cplusplus/ARR02-CPP.+Explicitly+specify+array+bounds%2C+even+if+implicitly+defined+by+an+initializer .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.ARR02,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.ARR37

Summary

Do not add or subtract an integer to a pointer to a non-array object. (See https://www.securecoding.cert.org/confluence/display/cplusplus/ARR37-CPP.+Do+not+add+or+subtract+an+integer+to+a+pointer+to+a+non-array+object .)

Configuration

See generic service options.

Rule CP1.DCL00

Summary

Const-qualify immutable objects. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL00-CPP.+Const-qualify+immutable+objects .)

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=CP1.DCL00,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=CP1.DCL00,show_declarations=all

Option single_assign
single_assign
-config=CP1.DCL00,single_assign=BOOL

Specify if an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const.

BOOL:

boolean. Accepted values are:

  • true: an uninitialized local variable declaration with a single assignment will be considered for converting the constness to const;

  • false: an uninitialized local variable declaration with a single assignment will not be considered for converting the constness to const;

Default:

-config=CP1.DCL00,single_assign=true

Option declarations
declarations
-config=CP1.DCL00,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=CP1.DCL00,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=CP1.DCL00,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule CP1.DCL01

Summary

Do not reuse variable names in subscopes. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL01-CPP.+Do+not+reuse+variable+names+in+subscopes .)

Configuration

See generic service options.

Rule CP1.DCL02

Summary

Use visually distinct identifiers. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL02-CPP.+Use+visually+distinct+identifiers .)

Description

The first 31 characters of any identifier (including macro and macro parameter names) must be unique (compared to all other identifiers visible in its scope) after applying the following ordered list of replacements:

  • replace 0 by O,

  • replace D by O,

  • replace 1 by I,

  • replace l by I,

  • replace 5 by S,

  • replace 2 by Z,

  • replace 8 by B,

  • replace rn by m,

  • replace h by n.

Configuration

See generic service options.

Option similar_map
similar_map
-config=CP1.DCL02,similar_map={MATCH_ID, MAPPING},...

Specify mappings of identifiers to their canonical form.

The configuration’s content is a list of identifier mappings.

MATCH_ID:

the identifier for the selected entities.

MAPPING:

. Accepted forms are:

  • std(REGEX): matches a service

  • min(NUMBER,CASE): the identifier prefix of length NUMBER, (after convertion to upper-case, if CASE is case_insensitive), is the canonical form

  • REPLACER[||REPLACER]*): a list of alternative REPLACERs (see the -replacer global configuration) defining the replacements that map the identifier to its canonical forms

CASE

accepted forms are:

  • case_sensitive: the identifier is case-sensitive

  • case_insensitive: the identifier is case-insensitive and the canonical form has all letters converted to upper-case

Default:

-config=CP1.DCL02,similar_map={all_identifiers, "substr(0,31)|replace('rn','m')|tr('0D1l528h','OOIISZBn')"}

Option ignored_decls
ignored_decls
-config=CP1.DCL02,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=CP1.DCL02,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.DCL03

Summary

Use a static assertion to test the value of a constant expression. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL03-CPP.+Use+a+static+assertion+to+test+the+value+of+a+constant+expression .)

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CP1.DCL03,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CP1.DCL03,macro_argument_context={}

Option macros
macros
-config=CP1.DCL03,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.DCL04

Summary

Do not declare more than one variable per declaration. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL04-CPP.+Do+not+declare+more+than+one+variable+per+declaration .)

Configuration

See generic service options.

Option contexts
contexts
-config=CP1.DCL04,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CP1.DCL06

Summary

Use meaningful symbolic constants to represent literal values in program logic. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL06-CPP.+Use+meaningful+symbolic+constants+to+represent+literal+values+in+program+logic .)

Configuration

See generic service options.

Option literal_matches
literal_matches
-config=CP1.DCL06,literal_matches={TAG, {LIT_COND,...}},...

Specify what is a magic constant.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

LIT_COND:

literal condition. Accepted alternatives are:

  • {ancestors, CTXT}: .

    CTXT:

    a -context_selector identifier or a matcher expression used to select the contexts.

  • {exact_macro_expansion}: an exact macro expansion.

  • {paren_macro_expansion}: a parenthesized macro expansion.

  • {in_macro_body}: literal is in macro body.

  • {expanded_from_macro, MACRO_MATCHER}: expanded from matching macro.

    MACRO_MATCHER:

    a -macro_selector identifier or a matcher expression used to select the macros.

  • {text, TEXT_RE}: regular expression to match literal.

    TEXT_RE:

    constant text matcher.

  • {character_literal}: character literal.

  • {wide_char_literal}: wide char literal.

  • {utf16_char_literal}: utf16 char literal.

  • {utf32_char_literal}: utf32 char literal.

  • {floating_literal}: floating literal.

  • {integer_literal}: integer literal.

  • {string_literal}: string literal.

  • {wide_string_literal}: wide string literal.

  • {utf8_string_literal}: utf8 string literal.

  • {utf16_string_literal}: utf16 string literal.

  • {utf32_string_literal}: utf32 string literal.

Default:

-config=CP1.DCL06,literal_matches={hide, {{paren_macro_expansion}}}, {hide, {{integer_literal}, {text, "^(0|-?1|2)[LUlu]*$"}}}, {hide, {{character_literal}, {text, "^'.'$"}}}, {hide, {{string_literal}, {text, "^\".?\"$"}}}, {hide, {{ancestors, __indirect_init_contexts}}}

Option literal_kinds
literal_kinds
-config=CP1.DCL06,literal_kinds=LIT,...

Specify the kinds of literals to be checked.

{LIT,…}:

the literal families to be checked. Accepted members are:

  • floating_literal: floating literal;

  • integer_literal: integer literal;

  • character_literal: character literal;

  • string_literal: string literal;

  • ordinary: ordinary character or string literal;

  • wide: wide character or string literal;

  • utf16: utf16 character or string literal;

  • utf32: utf32 char literal;

  • utf8: utf8 string literal;

Default:

-config=CP1.DCL06,literal_kinds=character_literal, integer_literal, floating_literal, string_literal

Option literals
literals
-config=CP1.DCL06,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule CP1.DCL07

Summary

Minimize the scope of variables and methods. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL07-CPP.+Minimize+the+scope+of+variables+and+methods .)

Description

Reports any variable for which one of the following holds:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • it is used in a single file but declared in a different file.

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.DCL07,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=CP1.DCL07,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule CP1.DCL13

Summary

Declare function parameters that are pointers to values not changed by the function as const. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL13-CPP.+Declare+function+parameters+that+are+pointers+to+values+not+changed+by+the+function+as+const .)

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=CP1.DCL13,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=CP1.DCL13,show_declarations=all

Option declarations
declarations
-config=CP1.DCL13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=CP1.DCL13,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=CP1.DCL13,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule CP1.DCL15

Summary

Declare file-scope objects or functions that do not need external linkage in an unnamed namespace. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL15-CPP.+Declare+file-scope+objects+or+functions+that+do+not+need+external+linkage+in+an+unnamed+namespace .)

Description

A function or variable will be reported if all the following hold:

  • the function or variable has linkage;

  • if it is referenced, then all references to it are in the same function;

  • the declaration or definition is not in a public API file. A file can be declared part of a public API using -public_files;

  • it is not declared in an anonymous namespace.

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.DCL15,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.DCL16

Summary

Use ‘L’, not ‘l’, to indicate a long value. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL16-CPP.+Use+%27L%27%2C+not+%27l%27%2C+to+indicate+a+long+value .)

Configuration

See generic service options.

Option literals
literals
-config=CP1.DCL16,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule CP1.DCL30

Summary

Declare objects with appropriate storage durations. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL30-CPP.+Declare+objects+with+appropriate+storage+durations .)

Description

An object with automatic storage must not have its address:

  • assigned to another automatic object of larger scope; or

  • assigned to a static object; or

  • returned by a function.

Configuration

See generic service options.

Rule CP1.DCL36

Summary

Do not declare an identifier with conflicting linkage classifications. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL36-CPP.+Do+not+declare+an+identifier+with+conflicting+linkage+classifications .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.DCL36,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.DCL53

Summary

Do not write syntactically ambiguous declarations. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL53-CPP.+Do+not+write+syntactically+ambiguous+declarations .)

Description

Declarations must not be syntactically ambiguous.

Note that, for this service, the report category is the diagnostic identifier.

Imprecision

False negatives are present because the implementation relies on parser diagnostics.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.DCL53,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.DCL57

Summary

Functions declared with [[noreturn]] must return void. (See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL57-CPP.+Functions+declared+with+%5B%5Bnoreturn%5D%5D+must+return+void .)

Description

Noreturn functions must not have return expressions.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.DCL57,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.ERR01

Summary

Use ferror() rather than errno to check for FILE stream errors. (See https://www.securecoding.cert.org/confluence/display/cplusplus/ERR01-CPP.+Use+ferror%28%29+rather+than+errno+to+check+for+FILE+stream+errors .)

Configuration

See generic service options.

Option macros
macros
-config=CP1.ERR01,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=CP1.ERR01,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.ERR36

Summary

Multiple catch handlers to a try block should order their exceptions from most derived to most basic. (See https://www.securecoding.cert.org/confluence/display/cplusplus/ERR36-CPP.+Multiple+catch+handlers+to+a+try+block+should+order+their+exceptions+from+most+derived+to+most+basic .)

Configuration

See generic service options.

Rule CP1.EXP00

Summary

Use parentheses for precedence of operation. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP00-CPP.+Use+parentheses+for+precedence+of+operation .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=CP1.EXP00,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule CP1.EXP05

Summary

Do not use C-style casts. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP05-CPP.+Do+not+use+C-style+casts .)

Configuration

See generic service options.

Option casts
casts
-config=CP1.EXP05,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CP1.EXP06

Summary

Operands to the sizeof operator should not contain side effects. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP06-CPP.+Operands+to+the+sizeof+operator+should+not+contain+side+effects .)

Configuration

See generic service options.

Option effects
effects
-config=CP1.EXP06,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule CP1.EXP09

Summary

Use sizeof to determine the size of a type or variable. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP09-CPP.+Use+sizeof+to+determine+the+size+of+a+type+or+variable .)

Configuration

See generic service options.

Option calls
calls
-config=CP1.EXP09,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CP1.EXP12

Summary

Do not ignore values returned by functions or methods. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP12-CPP.+Do+not+ignore+values+returned+by+functions+or+methods .)

Description

Reports if the value returned by a non-void function is not used.

Notes:

  • calls to a non-void function whose return value is ignored are reported;

  • calls where the return value is cast to void are not individually reported as the explicit cast to void is taken to be a deviation request by the user.

  • all calls are included in a statistical summary for the program and the called function;

  • the summary provides:

    • the number of calls to the function,

    • the number of times the return value is ignored but this was expected,

    • the number of times the return value is cast to void and

    • the number of times it is ignored unexpectedly;

  • the number of samples shown can be changed using the use_samples service configuration.

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=CP1.EXP12,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option use_samples
use_samples
-config=CP1.EXP12,use_samples={TAG, MAX},...

Specify the maximum number of samples to be output.

The configuration’s content is a list of return use tags (ignored, to_void, used) with the maximum number of samples to be output; if a use tag is not specified, then all calls matching the tag will be shown as violations.

TAG:

tag indicating the return use. Accepted values are:

  • used: return value is used;

  • ignored: return value is ignored;

  • to_void: return value is cast to void;

MAX:

maximum number of samples to be shown. It must be an integer greater than or equal to -1.

Default:

-config=CP1.EXP12,use_samples={ignored, -1}, {to_void, 1}, {used, 1}

Option calls
calls
-config=CP1.EXP12,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=CP1.EXP12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.EXP14

Summary

Do not use reinterpret_cast on pointers to class objects with multiple inheritance. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP14-CPP.+Do+not+use+reinterpret_cast+on+pointers+to+class+objects+with+multiple+inheritence .)

Configuration

See generic service options.

Option casts
casts
-config=CP1.EXP14,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CP1.EXP15

Summary

Beware of integer promotion when performing bitwise operations on chars or shorts. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP15-CPP.+Beware+of+integer+promotion+when+performing+bitwise+operations+on+chars+or+shorts .)

Description

If an operand of << or ~ has type signed or unsigned char or short, then the result must be immediately cast to the type of the operand.

Configuration

See generic service options.

Rule CP1.EXP17

Summary

Treat relational and equality operators as if they were nonassociative. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP17-CPP.+Treat+relational+and+equality+operators+as+if+they+were+nonassociative .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=CP1.EXP17,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule CP1.EXP19

Summary

Do not perform assignments in conditional expressions. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP19-CPP.+Do+not+perform+assignments+in+conditional+expressions .)

Configuration

See generic service options.

Option statements
statements
-config=CP1.EXP19,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CP1.EXP19,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CP1.EXP30

Summary

Do not depend on order of evaluation between sequence points. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP30-CPP.+Do+not+depend+on+order+of+evaluation+between+sequence+points .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule CP1.EXP31

Summary

Avoid side effects in assertions. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP31-CPP.+Avoid+side+effects+in+assertions .)

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CP1.EXP31,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CP1.EXP31,macro_argument_context={}

Option macros
macros
-config=CP1.EXP31,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.EXP35

Summary

Do not cast away a const qualification. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP35-CPP.+Do+not+cast+away+a+const+qualification .)

Configuration

See generic service options.

Option casts
casts
-config=CP1.EXP35,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CP1.EXP36

Summary

Do not convert pointers into more strictly aligned pointer types. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP36-CPP.+Do+not+convert+pointers+into+more+strictly+aligned+pointer+types .)

Configuration

See generic service options.

Option casts
casts
-config=CP1.EXP36,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CP1.EXP37

Summary

Call variadic functions with the arguments intended by the API. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP37-CPP.+Call+variadic+functions+with+the+arguments+intended+by+the+API .)

Description

Checks that:

  • any call to a function has an explicit protoype declaration;

  • the number of arguments passed to the function match the number of parameters;

  • the type of each argument is compatible with the declared type of the parameter;

  • if the parameter type is a pointer, then the pointee type of the argument is compatible with the pointee type of the parameter;

  • calls to type-generic functions in <math.h> that expect real values do not have complex-valued arguments.

Configuration

See generic service options.

Option calls
calls
-config=CP1.EXP37,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=CP1.EXP37,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option casts
casts
-config=CP1.EXP37,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option contexts
contexts
-config=CP1.EXP37,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CP1.EXP52

Summary

Do not rely on side effects in unevaluated operands. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP52-CPP.+Do+not+rely+on+side+effects+in+unevaluated+operands .)

Description

Side effects must not be included in unevaluated contexts.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.EXP52,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.EXP54

Summary

Do not access an object outside of its lifetime. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP54-CPP.+Do+not+access+an+object+outside+of+its+lifetime .)

Description

Variables must not be accessed outside of their lifetime.

Imprecision

False negatives are present because the lifetime of a variable is undecidable.

Consider the following piece of code:

struct S54 {
  void mem_fn54();
};

void f54() {
  S54 *s;
  s->mem_fn54();
}

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.EXP54,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.EXP57

Summary

Do not cast or delete pointers to incomplete classes. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP57-CPP.+Do+not+cast+or+delete+pointers+to+incomplete+classes .)

Description

There must be no casts or pointer deletes to incomplete classes.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.EXP57,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.EXP58

Summary

Do not pass a reference or nontrivially copyable type to va_start. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP58-CPP.+Do+not+pass+a+reference+or+nontrivially+copyable+type+to+va_start .)

Description

A reference or nontrivially copyable type must not be passed to va_start.

Note that, for this service, the report category is the diagnostic identifier.

Imprecision

False negatives are present because whether a reference or nontrivially copyable type is passed to va_start is undecidable.

Consider the following piece of code:

void f3(std::string s, ...) {
  va_list list;
  va_start(list, s);
  std::cout << s << ", " << va_arg(list, int);
  va_end(list);
}

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.EXP58,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.EXP59

Summary

Use offsetof() on valid types and members. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP59-CPP.+Use+offsetof%28%29+on+valid+types+and+members .)

Description

In an invocation of offsetof() macro the type argument must not pass a standard-layout class and the member designator argument must not pass a bit-field, static data member, or function member.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.EXP59,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.EXP60

Summary

Do not pass a nonstandard-layout type object across execution boundaries. (See https://www.securecoding.cert.org/confluence/display/cplusplus/EXP60-CPP.+Do+not+pass+a+nonstandard-layout+type+object+across+execution+boundaries .)

Description

A nonstandard-layout type object must not be passed across execution boundaries.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.EXP60,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.FIO07

Summary

Prefer fseek() to rewind(). (See https://www.securecoding.cert.org/confluence/display/cplusplus/FIO07-CPP.+Prefer+fseek%28%29+to+rewind%28%29 .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.FIO07,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.FIO12

Summary

Prefer setvbuf() to setbuf(). (See https://www.securecoding.cert.org/confluence/display/cplusplus/FIO12-CPP.+Prefer+setvbuf%28%29+to+setbuf%28%29 .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.FIO12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.FLP30

Summary

Do not use floating point variables as loop counters. (See https://www.securecoding.cert.org/confluence/display/cplusplus/FLP30-CPP.+Do+not+use+floating+point+variables+as+loop+counters .)

Configuration

See generic service options.

Option for_counter
for_counter
-config=CP1.FLP30,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Rule CP1.FLP31

Summary

Do not call functions expecting real values with complex values. (See https://www.securecoding.cert.org/confluence/display/cplusplus/FLP31-CPP.+Do+not+call+functions+expecting+real+values+with+complex+values .)

Configuration

See generic service options.

Option calls
calls
-config=CP1.FLP31,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=CP1.FLP31,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CP1.INT02

Summary

Understand integer conversion rules. (See https://www.securecoding.cert.org/confluence/display/cplusplus/INT02-CPP.+Understand+integer+conversion+rules .)

Configuration

See generic service options.

Option etypes
etypes
-config=CP1.INT02,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule CP1.INT07

Summary

Use only explicitly signed or unsigned char type for numeric values. (See https://www.securecoding.cert.org/confluence/display/cplusplus/INT07-CPP.+Use+only+explicitly+signed+or+unsigned+char+type+for+numeric+values .)

Configuration

See generic service options.

Option calls
calls
-config=CP1.INT07,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CP1.INT09

Summary

Ensure enumeration constants map to unique values. (See https://www.securecoding.cert.org/confluence/display/cplusplus/INT09-CPP.+Ensure+enumeration+constants+map+to+unique+values .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.INT09,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.INT11

Summary

Take care when converting from pointer to integer or integer to pointer. (See https://www.securecoding.cert.org/confluence/display/cplusplus/INT11-CPP.+Take+care+when+converting+from+pointer+to+integer+or+integer+to+pointer .)

Description

A pointer type must not be cast to an integer type and an integer type must not be cast to a pointer type.

Explicit casts from integral constants to pointers are permitted to allow addressing of hardware memory mapped areas.

Configuration

See generic service options.

Option casts
casts
-config=CP1.INT11,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule CP1.INT12

Summary

Do not make assumptions about the type of a plain int bit-field when used in an expression. (See https://www.securecoding.cert.org/confluence/display/cplusplus/INT12-CPP.+Do+not+make+assumptions+about+the+type+of+a+plain+int+bit-field+when+used+in+an+expression .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.INT12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=CP1.INT12,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule CP1.INT13

Summary

Use bitwise operators only on unsigned operands. (See https://www.securecoding.cert.org/confluence/display/cplusplus/INT13-CPP.+Use+bitwise+operators+only+on+unsigned+operands .)

Configuration

See generic service options.

Option statements
statements
-config=CP1.INT13,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CP1.INT13,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CP1.INT34

Summary

Do not shift a negative number of bits or more bits than exist in the operand. (See https://www.securecoding.cert.org/confluence/display/cplusplus/INT34-CPP.+Do+not+shift+a+negative+number+of+bits+or+more+bits+than+exist+in+the+operand .)

Configuration

See generic service options.

Rule CP1.MEM02

Summary

Immediately cast the result of a memory allocation function call into a pointer to the allocated type. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MEM02-CPP.+Immediately+cast+the+result+of+a+memory+allocation+function+call+into+a+pointer+to+the+allocated+type .)

Configuration

See generic service options.

Option calls
calls
-config=CP1.MEM02,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule CP1.MEM08

Summary

Use new and delete rather than raw memory allocation and deallocation. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MEM08-CPP.+Use+new+and+delete+rather+than+raw+memory+allocation+and+deallocation .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.MEM08,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.MSC00

Summary

Compile cleanly at high warning levels. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC00-CPP.+Compile+cleanly+at+high+warning+levels .)

Configuration

See generic service options.

Option hidden_options
hidden_options
-config=CP1.MSC00,hidden_options={TAGS, TOOL, {OPTION_MATCHER,...}},...

Specify tags for command lines that match the option selectors.

The configuration’s content is list of tagged option matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TOOL:

tool kind. Accepted values are:

  • compiler: compiler tool;

  • linker: linker tool;

OPTION_MATCHER:

option matcher string. Accepted forms are:

  • ^REGEX$: option matches ^REGEX$

  • !OPTION_MATCHER: option does not match OPTION_MATCHER

  • ID: option matches one of the patterns listed in ecl variable ID (a name beginning with a letter)

  • TEXT: option matches string TEXT

REGEX

accepted forms are:


Rule CP1.MSC01

Summary

Strive for logical completeness. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC01-CPP.+Strive+for+logical+completeness .)

Configuration

See generic service options.

Option else_empty
else_empty
-config=CP1.MSC01,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=CP1.MSC01,else_empty={missing, "none()"}, {null, "none()"}, {empty_compound, "any()"}

Option ignored_comments
ignored_comments
-config=CP1.MSC01,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option declarations
declarations
-config=CP1.MSC01,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.MSC04

Summary

Use comments consistently and in a readable fashion. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC04-CPP.+Use+comments+consistently+and+in+a+readable+fashion .)

Configuration

See generic service options.

Option comments
comments
-config=CP1.MSC04,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=CP1.MSC04,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=CP1.MSC04,code_lines=0

Option ignored_comments
ignored_comments
-config=CP1.MSC04,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=CP1.MSC04,ignored_comments=__doxygen_comments

Rule CP1.MSC05

Summary

Do not manipulate time_t typed values directly. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC05-CPP.+Do+not+manipulate+time_t+typed+values+directly .)

Configuration

See generic service options.

Option statements
statements
-config=CP1.MSC05,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=CP1.MSC05,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule CP1.MSC12

Summary

Detect and remove code that has no effect. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC12-CPP.+Detect+and+remove+code+that+has+no+effect .)

Configuration

See generic service options.

Rule CP1.MSC18

Summary

Finish every set of statements associated with a case label with a break statement. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC18-CPP.+Finish+every+set+of+statements+associated+with+a+case+label+with+a+break+statement .)

Configuration

See generic service options.

Option terminals
terminals
-config=CP1.MSC18,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=CP1.MSC18,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=CP1.MSC18,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule CP1.MSC20

Summary

Do not use a switch statement to transfer control into a complex block. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC20-CPP.+Do+not+use+a+switch+statement+to+transfer+control+into+a+complex+block .)

Configuration

See generic service options.

Option switch_clauses
switch_clauses
-config=CP1.MSC20,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=CP1.MSC20,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule CP1.MSC22

Summary

Do not define static private members. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC22-CPP.+Do+not+define+static+private+members .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.MSC22,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.MSC30

Summary

Do not use the rand() function for generating pseudorandom numbers. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC30-CPP.+Do+not+use+the+rand%28%29+function+for+generating+pseudorandom+numbers .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.MSC30,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.MSC54

Summary

Value-returning functions must return a value from all exit paths. (See https://www.securecoding.cert.org/confluence/display/cplusplus/MSC54-CPP.+Value-returning+functions+must+return+a+value+from+all+exit+paths .)

Description

Non-void functions must return a value from all exit paths.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.MSC54,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.MSC55

Summary

Do not return from a function declared [[noreturn]]. (See https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=143294580 .)

Description

A function declared [[noreturn]] must not return.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.MSC55,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.OOP52

Summary

Do not delete a polymorphic object without a virtual destructor. (See https://www.securecoding.cert.org/confluence/display/cplusplus/OOP52-CPP.+Do+not+delete+a+polymorphic+object+without+a+virtual+destructor .)

Description

A polymorphic object must not be deleted without a virtual destructor.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.OOP52,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.OOP53

Summary

Write constructor member initializers in the canonical order. (See https://www.securecoding.cert.org/confluence/display/cplusplus/OOP53-CPP.+Write+constructor+member+initializers+in+the+canonical+order .)

Description

Constructor member initializers must be written in the canonical order.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=CP1.OOP53,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule CP1.PRE00

Summary

Avoid defining macros. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE00-CPP.+Avoid+defining+macros .)

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CP1.PRE00,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CP1.PRE00,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=CP1.PRE00,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.PRE01

Summary

Use parentheses within macros around parameter names. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE01-CPP.+Use+parentheses+within+macros+around+parameter+names .)

Configuration

See generic service options.

Option param_parentheses
param_parentheses
-config=CP1.PRE01,param_parentheses=CONDS,...

Specify conditions when parameter parentheses are not required.

The configuration’s content is a short-circuit sequence of macro parameter parentheses.

CONDS:

conditions for parameter parentheses. Accepted forms are:

  • binary_op(): the parameter is an argument to a binary operator

  • unary_op(): the parameter is an argument to a unary operator

  • conditional_op(): the parameter is an argument to a conditional operator

  • pre(PRE_POST_EXPR): the tokens before the parameter must match PRE_POST_EXPR

  • post(PRE_POST_EXPR): the tokens after the parameter must match PRE_POST_EXPR

  • pre_post(PRE_POST_EXPR0,PRE_POST_EXPR1): the tokens before the parameter must match PRE_POST_EXPR0 and the tokens after the parameter must match PRE_POST_EXPR1

PRE_POST_EXPR

accepted forms are:

  • QSTRING: quoted token sequence

  • QSTRING||PRE_POST_EXPR: alternative quoted token sequences

Default:

-config=CP1.PRE01,param_parentheses="pre('->'||'.')"

Option macros
macros
-config=CP1.PRE01,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.PRE02

Summary

Macro replacement lists should be parenthesized. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE02-CPP.+Macro+replacement+lists+should+be+parenthesized .)

Configuration

See generic service options.

Option macros
macros
-config=CP1.PRE02,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.PRE03

Summary

Prefer typedefs to defines for encoding types. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE03-CPP.+Prefer+typedefs+to+defines+for+encoding+types .)

Configuration

See generic service options.

Option macros
macros
-config=CP1.PRE03,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.PRE04

Summary

Do not reuse a standard header file name. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE04-CPP.+Do+not+reuse+a+standard+header+file+name .)

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=CP1.PRE04,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=CP1.PRE04,reserved_standard="min(c++03)"

Rule CP1.PRE06

Summary

Enclose header files in an inclusion guard. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE06-CPP.+Enclose+header+files+in+an+inclusion+guard .)

Configuration

See generic service options.

Option directives
directives
-config=CP1.PRE06,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule CP1.PRE07

Summary

Avoid using repeated question marks. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE07-CPP.+Avoid+using+repeated+question+marks .)

Configuration

See generic service options.

Rule CP1.PRE08

Summary

Guarantee that header file names are unique. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE08-CPP.+Guarantee+that+header+file+names+are+unique .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=CP1.PRE08,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=CP1.PRE08,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule CP1.PRE12

Summary

Do not define unsafe macros. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE12-CPP.+Do+not+define+unsafe+macros .)

Configuration

See generic service options.

Option macros
macros
-config=CP1.PRE12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.PRE31

Summary

Avoid side-effects in arguments to unsafe macros. (See https://www.securecoding.cert.org/confluence/display/cplusplus/PRE31-CPP.+Avoid+side-effects+in+arguments+to+unsafe+macros .)

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=CP1.PRE31,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CP1.PRE31,macro_argument_context={}

Option macros
macros
-config=CP1.PRE31,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule CP1.STR04

Summary

Use plain char for characters in the basic character set. (See https://www.securecoding.cert.org/confluence/display/cplusplus/STR04-CPP.+Use+plain+char+for+characters+in+the+basic+character+set .)

Configuration

See generic service options.

Rule CP1.STR34

Summary

Cast characters to unsigned types before converting to larger integer sizes. (See https://www.securecoding.cert.org/confluence/display/cplusplus/STR34-CPP.+Cast+characters+to+unsigned+types+before+converting+to+larger+integer+sizes .)

Configuration

See generic service options.

Rule CP1.STR36

Summary

Do not specify the bound of a character array initialized with a string literal. (See https://www.securecoding.cert.org/confluence/display/cplusplus/STR36-CPP.+Do+not+specify+the+bound+of+a+character+array+initialized+with+a+string+literal .)

Configuration

See generic service options.

Option declarations
declarations
-config=CP1.STR36,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule CP1.STR37

Summary

Arguments to character handling functions must be representable as an unsigned char. (See https://www.securecoding.cert.org/confluence/display/cplusplus/STR37-CPP.+Arguments+to+character+handling+functions+must+be+representable+as+an+unsigned+char .)

Configuration

See generic service options.

Option calls
calls
-config=CP1.STR37,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option macro_argument_context
macro_argument_context
-config=CP1.STR37,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=CP1.STR37,macro_argument_context={}

Option macros
macros
-config=CP1.STR37,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


The BUGSENG EMET Services

This section contains documentation on ECLAIR services for specific exceeded metric reporting.

For each of the supported metrics, the identifier for the corresponding rule is obtained by adding the prefix EMET, thereby obtaining, for example: EMET.B.VOCF_FUNC, EMET.HIS.GOTO, …

Note that the page numbers included in the references to the HIS Source Code Metrics [13] in the ECLAIR service summaries are for the PDF version of [13] .

Rule EMET.B.ACPATH_FUNC

Summary

Report exceeded metric B.ACPATH_FUNC (number of acyclic paths through a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.ACPATH_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.ACPATH_FUNC,metric_show={B.ACPATH_FUNC, 80}

Option declarations
declarations
-config=EMET.B.ACPATH_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.ALLSTMTS_FUNC

Summary

Report exceeded metric B.ALLSTMTS_FUNC (total number of statements except block, empty statements, labels and declarations in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.ALLSTMTS_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.ALLSTMTS_FUNC,metric_show={B.ALLSTMTS_FUNC, 50}

Option declarations
declarations
-config=EMET.B.ALLSTMTS_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.BLOCKNEST_FUNC

Summary

Report exceeded metric B.BLOCKNEST_FUNC (depth of nesting of blocks in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.BLOCKNEST_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.BLOCKNEST_FUNC,metric_show={B.BLOCKNEST_FUNC, 1}

Option declarations
declarations
-config=EMET.B.BLOCKNEST_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.CALLER_PROG

Summary

Report exceeded metric B.CALLER_PROG (number of functions calling a function in a program).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.CALLER_PROG,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.CALLER_PROG,metric_show={B.CALLER_PROG, 5}

Option declarations
declarations
-config=EMET.B.CALLER_PROG,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.CALL_FUNC

Summary

Report exceeded metric B.CALL_FUNC (number of direct and indirect function calls in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.CALL_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.CALL_FUNC,metric_show={B.CALL_FUNC, 7}

Option declarations
declarations
-config=EMET.B.CALL_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.CALL_UNIT

Summary

Report exceeded metric B.CALL_UNIT (number of direct and indirect function calls in a unit).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.CALL_UNIT,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.CALL_UNIT,metric_show={B.CALL_UNIT, 7}

Option declarations
declarations
-config=EMET.B.CALL_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.CHAR_LINE

Summary

Report exceeded metric B.CHAR_LINE (number of characters in a logical source line).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.CHAR_LINE,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.CHAR_LINE,metric_show={B.CHAR_LINE, 80}

Option declarations
declarations
-config=EMET.B.CHAR_LINE,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.COMF_JFUNC

Summary

Report exceeded metric B.COMF_JFUNC (comment density in a function in the project).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.COMF_JFUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.COMF_JFUNC,metric_show={B.COMF_JFUNC, <0.2}

Option metric_decimal_digits
metric_decimal_digits
-config=EMET.B.COMF_JFUNC,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.

Default:

-config=EMET.B.COMF_JFUNC,metric_decimal_digits={B.COMF_JFUNC, 1}

Option declarations
declarations
-config=EMET.B.COMF_JFUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.COMMENT_FUNC

Summary

Report exceeded metric B.COMMENT_FUNC (number of comments in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.COMMENT_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.COMMENT_FUNC,metric_show={B.COMMENT_FUNC, <2}

Option declarations
declarations
-config=EMET.B.COMMENT_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.EXID_PROG

Summary

Report exceeded metric B.EXID_PROG (number of external identifiers in a program).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.EXID_PROG,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.EXID_PROG,metric_show={B.EXID_PROG, 10}

Option declarations
declarations
-config=EMET.B.EXID_PROG,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.HARRISON_FUNC

Summary

Report exceeded metric B.HARRISON_FUNC (Harrison’s Complexity Metric).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.HARRISON_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.HARRISON_FUNC,metric_show={B.HARRISON_FUNC, 10}

Option declarations
declarations
-config=EMET.B.HARRISON_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.IFNEST_PIF

Summary

Report exceeded metric B.IFNEST_PIF (depth of nesting of if statements).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.IFNEST_PIF,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.IFNEST_PIF,metric_show={B.IFNEST_PIF, 4}

Option declarations
declarations
-config=EMET.B.IFNEST_PIF,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.LINES_FILE

Summary

Report exceeded metric B.LINES_FUNC (number of physical lines in a file).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.LINES_FILE,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.LINES_FILE,metric_show={B.LINES_FILE, 100}

Option declarations
declarations
-config=EMET.B.LINES_FILE,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.LINES_FUNC

Summary

Report exceeded metric B.LINES_FUNC (number of physical lines in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.LINES_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.LINES_FUNC,metric_show={B.LINES_FUNC, 50}

Option declarations
declarations
-config=EMET.B.LINES_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.LOGBOP_FUNC

Summary

Report exceeded metric B.LOGBOP_FUNC (number of && and || operators in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.LOGBOP_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.LOGBOP_FUNC,metric_show={B.LOGBOP_FUNC, 10}

Option declarations
declarations
-config=EMET.B.LOGBOP_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.LSLOCS_BLOCK

Summary

Report exceeded metric B.LSLOCS_BLOCK (number of logical source lines of code in a block).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.LSLOCS_BLOCK,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.LSLOCS_BLOCK,metric_show={B.LSLOCS_BLOCK, 20}

Option declarations
declarations
-config=EMET.B.LSLOCS_BLOCK,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.LSLOCS_FUNC

Summary

Report exceeded metric B.LSLOCS_FUNC (number of logical source lines of code in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.LSLOCS_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.LSLOCS_FUNC,metric_show={B.LSLOCS_FUNC, 20}

Option declarations
declarations
-config=EMET.B.LSLOCS_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.MCCABE_FUNC

Summary

Report exceeded metric B.MCCABE_FUNC (mcCabe’s original Complexity Metric).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.MCCABE_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.MCCABE_FUNC,metric_show={B.MCCABE_FUNC, 10}

Option declarations
declarations
-config=EMET.B.MCCABE_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.NAMED_PARAM_FUNC

Summary

Report exceeded metric B.NAMED_PARAM_FUNC (number of named function parameters in a function definition).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.NAMED_PARAM_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.NAMED_PARAM_FUNC,metric_show={B.NAMED_PARAM_FUNC, 5}

Option declarations
declarations
-config=EMET.B.NAMED_PARAM_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.NOELSE_FUNC

Summary

Report exceeded metric B.NOELSE_FUNC (number of if-else-if without an else in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.NOELSE_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.NOELSE_FUNC,metric_show={B.NOELSE_FUNC, 0}

Option declarations
declarations
-config=EMET.B.NOELSE_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.NPATH_FUNC

Summary

Report exceeded metric B.NPATH_FUNC (number of npaths through a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.NPATH_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.NPATH_FUNC,metric_show={B.NPATH_FUNC, 80}

Option declarations
declarations
-config=EMET.B.NPATH_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.PARAM_FUNC

Summary

Report exceeded metric B.PARAM_FUNC (number of parameters in a function definition).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.PARAM_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.PARAM_FUNC,metric_show={B.PARAM_FUNC, 1}

Option declarations
declarations
-config=EMET.B.PARAM_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.RETPOINTS_FUNC

Summary

Report exceeded metric B.RETPOINTS_FUNC (number of return points in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.RETPOINTS_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.RETPOINTS_FUNC,metric_show={B.RETPOINTS_FUNC, 1}

Option declarations
declarations
-config=EMET.B.RETPOINTS_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.SEMI_BLOCK

Summary

Report exceeded metric B.SEMI_BLOCK (number of statement-like language constructs in a unit).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.SEMI_BLOCK,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.SEMI_BLOCK,metric_show={B.SEMI_BLOCK, 20}

Option declarations
declarations
-config=EMET.B.SEMI_BLOCK,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STATL_FUNC

Summary

Report exceeded metric B.STATL_FUNC (number of references to local statically-allocated variables in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STATL_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STATL_FUNC,metric_show={B.STATL_FUNC, 10}

Option declarations
declarations
-config=EMET.B.STATL_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STATNL_FUNC

Summary

Report exceeded metric B.STATNL_FUNC (number of references to non-local statically-allocated variables in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STATNL_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STATNL_FUNC,metric_show={B.STATNL_FUNC, 10}

Option declarations
declarations
-config=EMET.B.STATNL_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STBAK_FUNC

Summary

Report exceeded metric B.STBAK_FUNC (number of back jumps in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STBAK_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STBAK_FUNC,metric_show={B.STBAK_FUNC, 0}

Option declarations
declarations
-config=EMET.B.STBAK_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STCYC_FUNC

Summary

Report exceeded metric B.STCYC_FUNC (mcCabe’s Complexity Metric).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STCYC_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STCYC_FUNC,metric_show={B.STCYC_FUNC, 10}

Option declarations
declarations
-config=EMET.B.STCYC_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STFCO_UNIT

Summary

Report exceeded metric B.STFCO_UNIT (function coupling in a unit).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STFCO_UNIT,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STFCO_UNIT,metric_show={B.STFCO_UNIT, 7}

Option declarations
declarations
-config=EMET.B.STFCO_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STFNC_UNIT

Summary

Report exceeded metric B.STFNC_UNIT (number of function definitions in a unit).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STFNC_UNIT,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STFNC_UNIT,metric_show={B.STFNC_UNIT, 10}

Option declarations
declarations
-config=EMET.B.STFNC_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STGTO_FUNC

Summary

Report exceeded metric B.STGTO_FUNC (number of goto statements in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STGTO_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STGTO_FUNC,metric_show={B.STGTO_FUNC, 0}

Option declarations
declarations
-config=EMET.B.STGTO_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STM22_UNIT

Summary

Report exceeded metric B.STM22_UNIT (number of statement-like language constructs in a translation unit).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STM22_UNIT,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STM22_UNIT,metric_show={B.STM22_UNIT, 100}

Option declarations
declarations
-config=EMET.B.STM22_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STM28_UNIT

Summary

Report exceeded metric B.STM28_UNIT (number of comments in a translation unit).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STM28_UNIT,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STM28_UNIT,metric_show={B.STM28_UNIT, 0}

Option metric_decimal_digits
metric_decimal_digits
-config=EMET.B.STM28_UNIT,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=EMET.B.STM28_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STMIF_FUNC

Summary

Report exceeded metric B.STMIF_FUNC (depth of nesting of iteration and selection statements).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STMIF_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STMIF_FUNC,metric_show={B.STMIF_FUNC, 2}

Option declarations
declarations
-config=EMET.B.STMIF_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STMT_HARRISON_FUNC

Summary

Report exceeded metric B.STMT_HARRISON_FUNC (statement-only variant of Harrison’s Complexity Metric).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STMT_HARRISON_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STMT_HARRISON_FUNC,metric_show={B.STMT_HARRISON_FUNC, 10}

Option declarations
declarations
-config=EMET.B.STMT_HARRISON_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STRET_FUNC

Summary

Report exceeded metric B.STRET_FUNC (number of returns in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STRET_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STRET_FUNC,metric_show={B.STRET_FUNC, 1}

Option declarations
declarations
-config=EMET.B.STRET_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STST1_FUNC

Summary

Report exceeded metric B.STST1_FUNC (number of statements not in a statement expression in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STST1_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STST1_FUNC,metric_show={B.STST1_FUNC, 50}

Option declarations
declarations
-config=EMET.B.STST1_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STST2_FUNC

Summary

Report exceeded metric B.STST2_FUNC (number of statements except block, empty statements and labels in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STST2_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STST2_FUNC,metric_show={B.STST2_FUNC, 50}

Option declarations
declarations
-config=EMET.B.STST2_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STST3_FUNC

Summary

Report exceeded metric B.STST3_FUNC (number of statements except block, empty statements, labels and declarations in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STST3_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STST3_FUNC,metric_show={B.STST3_FUNC, 50}

Option declarations
declarations
-config=EMET.B.STST3_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STSUB_FUNC

Summary

Report exceeded metric B.STSUB_FUNC (number of function calls in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STSUB_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STSUB_FUNC,metric_show={B.STSUB_FUNC, 7}

Option declarations
declarations
-config=EMET.B.STSUB_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.STXLN_FUNC

Summary

Report exceeded metric B.STXLN_FUNC (number of executable lines of code in a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.STXLN_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.STXLN_FUNC,metric_show={B.STXLN_FUNC, 50}

Option declarations
declarations
-config=EMET.B.STXLN_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.B.VOCF_FUNC

Summary

Report exceeded metric B.VOCF_FUNC (the VOCF language scope metric).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.B.VOCF_FUNC,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.B.VOCF_FUNC,metric_show={B.VOCF_FUNC, 4}

Option metric_decimal_digits
metric_decimal_digits
-config=EMET.B.VOCF_FUNC,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.

Default:

-config=EMET.B.VOCF_FUNC,metric_decimal_digits={B.VOCF_FUNC, 1}

Option declarations
declarations
-config=EMET.B.VOCF_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.CALLING

Summary

Report exceeded metric HIS.CALLING (number of calling functions).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.CALLING,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.CALLING,metric_show={HIS.CALLING, 5}

Option declarations
declarations
-config=EMET.HIS.CALLING,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.CALLS

Summary

Report exceeded metric HIS.CALLS (number of called functions).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.CALLS,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.CALLS,metric_show={HIS.CALLS, 7}

Option declarations
declarations
-config=EMET.HIS.CALLS,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.COMF

Summary

Report exceeded metric HIS.COMF (comment density).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.COMF,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.COMF,metric_show={HIS.COMF, <0.2}

Option metric_decimal_digits
metric_decimal_digits
-config=EMET.HIS.COMF,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.

Default:

-config=EMET.HIS.COMF,metric_decimal_digits={HIS.COMF, 1}

Option declarations
declarations
-config=EMET.HIS.COMF,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.GOTO

Summary

Report exceeded metric HIS.GOTO (number of goto statements).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.GOTO,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.GOTO,metric_show={HIS.GOTO, 0}

Option declarations
declarations
-config=EMET.HIS.GOTO,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.LEVEL

Summary

Report exceeded metric HIS.LEVEL (depth of nesting of a function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.LEVEL,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.LEVEL,metric_show={HIS.LEVEL, 4}

Option declarations
declarations
-config=EMET.HIS.LEVEL,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.PARAM

Summary

Report exceeded metric HIS.PARAM (number of function parameters).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.PARAM,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.PARAM,metric_show={HIS.PARAM, 5}

Option declarations
declarations
-config=EMET.HIS.PARAM,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.PATH

Summary

Report exceeded metric HIS.PATH (number of paths).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.PATH,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.PATH,metric_show={HIS.PATH, 80}

Option declarations
declarations
-config=EMET.HIS.PATH,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.RETURN

Summary

Report exceeded metric HIS.RETURN (number of return points).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.RETURN,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.RETURN,metric_show={HIS.RETURN, 1}

Option declarations
declarations
-config=EMET.HIS.RETURN,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.STMT

Summary

Report exceeded metric HIS.STMT (number of instructions per function).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.STMT,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.STMT,metric_show={HIS.STMT, 50}

Option declarations
declarations
-config=EMET.HIS.STMT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.VOCF

Summary

Report exceeded metric HIS.VOCF (language scope).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.VOCF,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.VOCF,metric_show={HIS.VOCF, 4}

Option metric_decimal_digits
metric_decimal_digits
-config=EMET.HIS.VOCF,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.

Default:

-config=EMET.HIS.VOCF,metric_decimal_digits={HIS.VOCF, 1}

Option declarations
declarations
-config=EMET.HIS.VOCF,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.ap_cg_cycle

Summary

Report exceeded metric HIS.ap_cg_cycle (number of recursions).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.ap_cg_cycle,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.ap_cg_cycle,metric_show={HIS.ap_cg_cycle, 0}

Option declarations
declarations
-config=EMET.HIS.ap_cg_cycle,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EMET.HIS.v_G

Summary

Report exceeded metric HIS.v_G (cyclomatic complexity).

Description

Reports the source code metrics that reach the specified threshold.

The metrics and their thresholds are specified using the metric_show service configuration.

Configuration

See generic service options.

Option metric_show
metric_show
-config=EMET.HIS.v_G,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=EMET.HIS.v_G,metric_show={HIS.v_G, 10}

Option metric_decimal_digits
metric_decimal_digits
-config=EMET.HIS.v_G,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=EMET.HIS.v_G,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


The ESA/BSSC C and C++ Coding Rules

Rule EP1.3

Summary

Write the software to conform to the coding language international standards, i.e. ISO/IEC 9899 and ISO/IEC 14882. (See page 14 of ESA-BSSC-C-CPP-2000 [16] .)This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptmarg STD.enumlist STD.extident STD.flexaray STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=EP1.3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=EP1.3,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=EP1.3,standards=c++03

Rule EP1.13

Summary

Comments in purely C programs must use the /*…*/ delimiters. (See page 17 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option comments
comments
-config=EP1.13,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule EP1.14

Summary

C++ programs should use the // to end of line convention. (See page 17 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option comments
comments
-config=EP1.14,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule EP1.17

Summary

Comments should never be used for “commenting out” code. (See page 19 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Sections of code in the compiled files must not be commented out.

Any non-compiled sources are reported as additional information.

Configuration

See generic service options.

Option comments
comments
-config=EP1.17,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=EP1.17,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=EP1.17,code_lines=0

Option ignored_comments
ignored_comments
-config=EP1.17,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=EP1.17,ignored_comments=__doxygen_comments

Rule EP1.22

Summary

Each case within a switch statement must contain a break statement or a “fall- through” comment. (See page 24 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option replacement_comment
replacement_comment
-config=EP1.22,replacement_comment={WHEN, COMMENT_MATCHER},...

Specify matchers for replacement comments.

The configuration’s content is a list of pairs indicating when a comment is needed and a comment matcher.

WHEN:

when to check a comment replacement. Accepted values are:

  • empty_default: switch default clause is empty;

  • missing_terminal: case or default clause has no terminal statement;

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=EP1.22,replacement_comment={missing_terminal, __fall_through_empty_case_comments}

Option terminals
terminals
-config=EP1.22,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=EP1.22,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=EP1.22,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule EP1.23

Summary

All switch statements shall have a default: clause. (See page 24 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Reports any switch statement that does not have a default label

Configuration

See generic service options.

Option declarations
declarations
-config=EP1.23,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EP1.28

Summary

Each file shall contain a standard comment header block. (See page 29 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option file_comment_block
file_comment_block
-config=EP1.28,file_comment_block={FILE_MATCHER, {{COMMENT_MATCHER, SEP},...}},...

Provide file matchers with matchers for their initial comment block.

The configuration’s content is an ordered list of file matchers with matchers for their initial comment block.

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

COMMENT_MATCHER:

regular expression or ‘*’. Accepted forms are:

  • FMT: format (see the -fmt global configuration content, template cmntfile__id_default_fmt) for a regular expression that matches the expected comment using fields:

file_name

the file name;

upper_case_file_name

the file name where the alphabetic characters are changed to uppercase.

  • *: depending on the value of the separator, the following comment lines can be skipped

SEP:

if matcher is a regular expression, this is the number of blank lines after comment; if matcher is * skip SEP comments. Accepted forms are:

  • MIN_MAX: the the number of blank lines is in the range MIN_MAX

Default:

-config=EP1.28,file_comment_block={"^.*\\.h$", {{"%{__simple_comment_fmt()}", 1..}}}, {"^.*\\.cc$", {{"%{__simple_comment_fmt()}", 1..}}}

Option ignored_comments
ignored_comments
-config=EP1.28,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule EP1.30

Summary

The contents of the interface file shall be surrounded by #ifdef/#endif preprocessor directives in order to avoid problems of multiple inclusion. (See page 30 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option directives
directives
-config=EP1.30,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule EP1.31

Summary

The interface file shall contain declarations only. (See page 31 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option declarations
declarations
-config=EP1.31,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EP1.32

Summary

Names shall not start with an underscore character (_). (See page 34 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=EP1.32,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=EP1.32,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=EP1.32,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=EP1.32,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=EP1.32,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=EP1.32,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=EP1.32,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule EP1.39

Summary

Pre-processor names shall consist of upper case words separated by underscore. (See page 35 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Reports if preprocessor names contain any lowercase letters

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=EP1.39,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=EP1.39,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=EP1.39,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=EP1.39,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=EP1.39,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=EP1.39,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=EP1.39,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule EP1.40

Summary

Variable names consist of one or more words where each word except the first is capitalised. (See page 35 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Reports if variable names do not start with a lowercase letter or contain an underscore character

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=EP1.40,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=EP1.40,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=EP1.40,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=EP1.40,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=EP1.40,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=EP1.40,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=EP1.40,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule EP1.41

Summary

Function names consist of one or more words where each word is capitalised. (See page 36 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Reports if function names do not start with an uppercase character or contain an underscore character

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=EP1.41,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=EP1.41,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=EP1.41,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=EP1.41,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=EP1.41,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=EP1.41,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=EP1.41,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule EP1.43

Summary

User defined type names shall begin with T or end with _t or _type. (See page 37 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=EP1.43,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=EP1.43,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=EP1.43,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=EP1.43,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=EP1.43,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=EP1.43,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=EP1.43,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule EP1.44

Summary

Class names shall begin with C or end with _c or _class. (See page 37 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=EP1.44,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=EP1.44,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=EP1.44,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=EP1.44,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=EP1.44,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=EP1.44,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=EP1.44,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule EP1.46

Summary

Each declaration should start on its own line and have an explanatory comment. (See page 41 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Reports a declaration that is not on a separate line or does not have an explanatory comment.

Reports any variable, tag, constant, type, friend or record declaration that does not have a comment immediately before the declaration or after and on the same line as the declaration.

The decl_document_selector service configuration can suppress the declarations checked and, for those not suppressed, specify the comment’s expected position relative to the associated declaration.

The selection of explanatory comments depends on two replacers (see the -replacer global configuration):

  • replacer anydecl_comment_repl selects and replaces the single comments that can contribute to the full documentation for the targeted declaration; this has the following options:

    • if the comment’s replacement is open (resp., close) that the comment is interpreted as the start (resp., end) of a block of declarations, and the replaced comment preceding the open comment is taken to be the explanatory comment for all the declarations in the block;

    • if the saved assoc list name (resp., qname) contains the name (resp., qualified name) of a declaration, then the comment is associated with the declaration’s documentation (independently of its position in the source);

  • replacer anydecl_document_repl checks the concatenated replacements from the previous selection with the following option:

    • if the saved assoc list name is non-empty, then the saved list of identifiers must include the targeted declaration’s name.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=EP1.46,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option decl_document_selector
decl_document_selector
-config=EP1.46,decl_document_selector={TAGS, CTXT, DECL, CONSTR, WHERE},...

Specifies the report tags for undocumented declarations.

The configuration’s content is list of tagged declaration and context matchers with indicators.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONSTR:

number and size constraints. Accepted forms are:

  • LIM: number or size constraint

  • LIM&&LIMS: the comments satisfy LIM and LIMS

LIM

accepted forms are:

  • num(EXPR): the minimum number of comments is specified by EXPR

  • size(EXPR): the minimum number of characters in the comments is specified by EXPR

EXPR

accepted forms are:

  • STRING: arithmetic expression whose variables are metrics

WHERE:

specifies where the explanatory comments are supposed to be found. Accepted values are:

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;

  • doxygen: doxygen-style comments;


Option declarations
declarations
-config=EP1.46,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option access
access
-config=EP1.46,access=ACCESS,...

Specify any access requirements; an empty set signifies that there are no special access requirements.

{ACCESS,…}:

set of access specifiers. Accepted members are:

  • empty: empty;

  • public: public;

  • protected: protected;

  • private: private;

Default:

-config=EP1.46,access={}

Option contexts
contexts
-config=EP1.46,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule EP1.54

Summary

For C++: all symbolic constants shall be provided using an enum or by using the const keyword. (See page 43 of ESA-BSSC-C-CPP-2000 [16] .)

Description

All symbolic constants should be used via an enum constant or the const keyword.

Allows as exceptions the direct use of values 0, 1, -1, 2 and -2 and single character strings or literals.

Configuration

See generic service options.

Option literals
literals
-config=EP1.54,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule EP1.55

Summary

Each variable shall have its own personal declaration, on its own line. (See page 43 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Each variable declarator must be on a separate line and have its own personal declaration.

Configuration

See generic service options.

Option contexts
contexts
-config=EP1.55,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule EP1.60

Summary

Each function shall have an explanatory header comment. (See page 48 of ESA-BSSC-C-CPP-2000 [16] .)

Description

Reports a function that does not have an explanatory comment.

Reports any function (that is, a function, method, constructor, conversion or destructor entity) that does not have an explanatory comment immediately before the one of its declarations or its definition.

Reports any parameter in the declaration that is not referred to in the function’s documentation.

The decl_document_selector service configuration can suppress the declarations checked and, for those not suppressed, specify the comment’s expected position relative to an associated declaration.

The selection of explanatory comments depends on two replacers (see the -replacer global configuration):

  • replacer function_comment_repl selects and replaces the single comments that can contribute to the full documentation for the targeted declaration; this has the following options:

    • if the comment’s replacement is open (resp., close) that the comment is interpreted as the start (resp., end) of a block of declarations, and the replaced comment preceding the open comment is taken to be the explanatory comment for all the functions declared in the block;

    • if the saved assoc list name (resp., qname) contains the name (resp., qualified name) of a function, then the comment is associated with the function’s documentation (independently of its position in the source);

  • replacer function_document_repl checks the concatenated replacements from the previous selection with the following option:

    • if the saved assoc list name is non-empty, then the saved list of identifiers must include the targeted function’s name.

    • if the saved assoc list param is non-empty, then the saved list of identifiers must include all the targeted function’s parameter names.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=EP1.60,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option decl_document_selector
decl_document_selector
-config=EP1.60,decl_document_selector={TAGS, CTXT, DECL, CONSTR, WHERE},...

Specifies the report tags for undocumented declarations.

The configuration’s content is list of tagged declaration and context matchers with indicators.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONSTR:

number and size constraints. Accepted forms are:

  • LIM: number or size constraint

  • LIM&&LIMS: the comments satisfy LIM and LIMS

LIM

accepted forms are:

  • num(EXPR): the minimum number of comments is specified by EXPR

  • size(EXPR): the minimum number of characters in the comments is specified by EXPR

EXPR

accepted forms are:

  • STRING: arithmetic expression whose variables are metrics

WHERE:

specifies where the explanatory comments are supposed to be found. Accepted values are:

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;

  • doxygen: doxygen-style comments;


Option declarations
declarations
-config=EP1.60,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EP1.62

Summary

A function, which takes no parameters, shall be declared with a void argument. [C only]. (See page 48 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option declarations
declarations
-config=EP1.62,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule EP1.66

Summary

A function may not return a reference or pointer to one of its own local automatic variables. (See page 50 of ESA-BSSC-C-CPP-2000 [16] .)

Description

It is shown if a pointer or reference to an object with automatic storage is returned by a function.

Configuration

See generic service options.

Rule EP1.91

Summary

The programmer should use the new C++ cast operators rather than the traditional C cast. (See page 74 of ESA-BSSC-C-CPP-2000 [16] .)

Configuration

See generic service options.

Option casts
casts
-config=EP1.91,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


The Google C++ Style Guide Rules

Rule GP3.Casting

Summary

Use C++ casts like static_cast<>(). Do not use other cast formats like int y = (int)x; or int y = int(x);. (See http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Casting .)

Configuration

See generic service options.

Option casts
casts
-config=GP3.Casting,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


The JPL Rules

Rule JC1.1

Summary

All C code shall conform to the ISO/IEC 9899-1999(E) standard for the C programming language, with no reliance on undefined or unspecified behavior. (See page 8 of NASA-JPL-C-2009 [3] .)

Description

Reports the following:

  • Undefined or unspecified behavior as given by the C99 standard [37] Annex J. Note that: there will be false negatives due to incomplete semantic information;

  • Any breaching of the implementation’s limits;

  • Any pragma directive;

  • Any non-standard directive such as warning.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.anonstct STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.arthinvl STD.asrtterm STD.bincondl STD.blkident STD.bsercheq STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charmult STD.charppif STD.charset STD.charstrl STD.charxwde STD.cissnest STD.cmntstle STD.cmpdltrl STD.flexaray STD.cnstenum STD.constobj STD.datetime STD.decllimt STD.defined STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.encderor STD.enumtype STD.eofnl STD.extident STD.extidsig STD.floatnrw STD.floatstd STD.fntpqual STD.forhdecl STD.fprscarg STD.fprscfmt STD.freesten STD.freestlb STD.freestnd STD.funojptr STD.funptrcv STD.hdrexpnd STD.hostmain STD.iddiflkg STD.iddollar STD.implfunc STD.inclexpd STD.inclfile STD.inclnest STD.indxcnst STD.indxvltl STD.intconvn STD.intfloat STD.intnlobj STD.ipconrep STD.linedir STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.mainargv STD.mainrtrn STD.membrecd STD.ncstinit STD.negshift STD.nexidsig STD.nodecltr STD.nonstdc STD.nullpntr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pragmdir STD.prepdirc STD.pteincmp STD.ptrintcv STD.ptrnconv STD.ptypnest STD.qsortord STD.recdnest STD.redltype STD.register STD.rvalsubs STD.shortsgn STD.stdcctxt STD.stdcprag STD.stdtypes STD.strerror STD.strincmp STD.strlitrl STD.tokenext STD.vaargast STD.volatltp

Configuration

See generic service options.

Option behaviors
behaviors
-config=JC1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=JC1.1,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Rule JC1.2

Summary

All code shall always be compiled with all compiler warnings enabled at the highest warning level available, with no errors or warnings resulting. All code shall further be verified with a JPL approved state-of-the-art static source code analyzer, with no errors or warnings resulting. (See page 8 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option hidden_options
hidden_options
-config=JC1.2,hidden_options={TAGS, TOOL, {OPTION_MATCHER,...}},...

Specify tags for command lines that match the option selectors.

The configuration’s content is list of tagged option matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TOOL:

tool kind. Accepted values are:

  • compiler: compiler tool;

  • linker: linker tool;

OPTION_MATCHER:

option matcher string. Accepted forms are:

  • ^REGEX$: option matches ^REGEX$

  • !OPTION_MATCHER: option does not match OPTION_MATCHER

  • ID: option matches one of the patterns listed in ecl variable ID (a name beginning with a letter)

  • TEXT: option matches string TEXT

REGEX

accepted forms are:


Rule JC1.4

Summary

There shall be no direct or indirect use of recursive function calls. (See page 10 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option declarations
declarations
-config=JC1.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=JC1.4,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule JC1.5

Summary

There shall be no use of dynamic memory allocation after task initialization. (See page 10 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=JC1.5,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=JC1.5,extra_statements={}

Option statements
statements
-config=JC1.5,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=JC1.5,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule JC1.11

Summary

The goto statement shall not be used. There shall be no calls to the functions setjmp or longjmp. (See page 12 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option statements
statements
-config=JC1.11,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=JC1.11,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option declarations
declarations
-config=JC1.11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=JC1.11,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule JC1.12

Summary

In an enumerator list, the “=” construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized. (See page 12 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option alias_exception
alias_exception
-config=JC1.12,alias_exception=EXCEPT

Specify if aliases are allowed.

EXCEPT

Accepted values are:

  • last: the last enum constant may be initialized with the previous enum constant identifier;

  • any: any enum constant may be initialized as the alias of another enum constant identifier;

  • none: no enum constant may be initialized as the alias of another enum constant identifier;

Default:

-config=JC1.12,alias_exception=none

Option declarations
declarations
-config=JC1.12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule JC1.13

Summary

Data objects shall be declared at the smallest possible level of scope. No declaration in an inner scope shall hide a declaration in an outer scope. (See page 13 of NASA-JPL-C-2009 [3] .)

Description

No identifier may use the same name as (and hence hide) an identifier in an outer scope.

For each variable, none of the following should hold:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • it is used in a single file but declared in a different file.

Configuration

See generic service options.

Option declarations
declarations
-config=JC1.13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=JC1.13,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule JC1.14

Summary

The return value of non-void functions shall be checked or used by each calling function, or explicitly cast to (void) if irrelevant. (See page 13 of NASA-JPL-C-2009 [3] .)

Description

Reports if the value returned by a non-void function is not used.

Notes:

  • calls to a non-void function whose return value is ignored are reported;

  • calls where the return value is cast to void are not individually reported as the explicit cast to void is taken to be a deviation request by the user.

  • all calls are included in a statistical summary for the program and the called function;

  • the summary provides:

    • the number of calls to the function,

    • the number of times the return value is ignored but this was expected,

    • the number of times the return value is cast to void and

    • the number of times it is ignored unexpectedly;

  • the number of samples shown can be changed using the use_samples service configuration.

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=JC1.14,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option use_samples
use_samples
-config=JC1.14,use_samples={TAG, MAX},...

Specify the maximum number of samples to be output.

The configuration’s content is a list of return use tags (ignored, to_void, used) with the maximum number of samples to be output; if a use tag is not specified, then all calls matching the tag will be shown as violations.

TAG:

tag indicating the return use. Accepted values are:

  • used: return value is used;

  • ignored: return value is ignored;

  • to_void: return value is cast to void;

MAX:

maximum number of samples to be shown. It must be an integer greater than or equal to -1.

Default:

-config=JC1.14,use_samples={ignored, -1}, {to_void, 1}, {used, 1}

Option calls
calls
-config=JC1.14,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=JC1.14,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule JC1.15

Summary

The validity of function parameters shall be checked at the start of each public function. The validity of function parameters to other functions shall be checked by either the function called or by the calling function. (See page 14 of NASA-JPL-C-2009 [3] .)

Description

There must be appropriate checks of values passed to standard libraries that have restricted input domains.

Imprecision

False negatives are present because there is no check if the conditions in the source code cover the function’s requirements and because only the standard libraries are checked.

Configuration

See generic service options.

Rule JC1.16

Summary

Assertions shall be used to perform basic sanity checks throughout the code. All functions of more than 10 lines should have at least one assertion. (See page 14 of NASA-JPL-C-2009 [3] .)

Description

Reports any function that has more than 10 logical lines of source code (lsloc) and does not have at least 1 assertion.

Note that:

Configuration

See generic service options.

Option function_size_metrics
function_size_metrics
-config=JC1.16,function_size_metrics={NAME, METRIC},...

Specify reference names with metrics.

The configuration’s content is an ordered list of reference names with metrics.

NAME:

a reference name.

METRIC:

a metric.

Default:

-config=JC1.16,function_size_metrics={params, B.PARAM_FUNC}, {size, B.LSLOCS_FUNC}

Option call_assertions
call_assertions
-config=JC1.16,call_assertions={TNAME, MIN, BOUND},...

Specify the complexity thresholds for an interesting function together with an expression defining a lower bound for the expected number of assertions in the function.

The configuration’s content is a list of pairs (MIN, BOUND) linking a complexity threshold with an evaluable term that indicates the minimum number of assertions; any function exceeding the complexity threshold but with less than the minimum number of assertions is reported.

TNAME:

a name already defined by the function_size_metrics service configuration for the metric whose value is to be compared to MIN.

MIN:

threshold for function size measured using TNAME. It must be an integer greater than or equal to 1.

BOUND:

an evaluable (Prolog-like) expression using complexity measures with variable names defined by the function_size_metrics service configuration; the number of special calls must be more that the value of this expression.

Default:

-config=JC1.16,call_assertions={size, 10, 1}

Option functions
functions
-config=JC1.16,functions=SPECIAL_FUN,...

Set of special function names.

{SPECIAL_FUN,…}:

a set of special function names. Accepted members are:

  • SPECIAL_FUN: function to be counted as special.

Default:

-config=JC1.16,functions=c_assert

Option special_macro
special_macro
-config=JC1.16,special_macro=SPECIAL_MACRO,...

Set of special macro names.

{SPECIAL_MACRO,…}:

a set of special macro names.set of special macro names. Accepted members are:

  • SPECIAL_MACRO: macro to be counted as special.

Default:

-config=JC1.16,special_macro=c_assert

Option declarations
declarations
-config=JC1.16,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule JC1.17

Summary

Typedefs that indicate size and signedness should be used in place of the basic types. (See page 15 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option naming
naming
-config=JC1.17,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=JC1.17,naming=jpl

Option declarations
declarations
-config=JC1.17,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=JC1.17,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule JC1.18

Summary

In compound expressions with multiple sub-expressions the intended order of evaluation shall be made explicit with parentheses. (See page 15 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=JC1.18,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule JC1.19

Summary

The evaluation of a Boolean expression shall have no side effects. (See page 15 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option statements
statements
-config=JC1.19,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=JC1.19,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule JC1.20

Summary

Use of the C preprocessor shall be limited to file inclusion and simple macros. (See page 16 of NASA-JPL-C-2009 [3] .)

Description

Reports the use of preprocessor directives except in the following cases:

  • non-recursive uses of #define where the macro does not have a variable argument list and the body expands to a complete syntactic unit or:

    • the macro is unused and does not include #, ##,

    • the macro is used but expands to a single identifier;

  • use of a macro for an inclusion guard.

Note that any use of conditional compilation will be reported.

Note that, for this service, the report category is the directive name.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=JC1.20,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=JC1.20,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=JC1.20,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule JC1.21

Summary

Macros shall not be #define‘d within a function or a block. (See page 16 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option macros
macros
-config=JC1.21,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule JC1.22

Summary

#undef shall not be used. (See page 16 of NASA-JPL-C-2009 [3] .)

Description

There must be no occurrence of the #undef directive.

Note that, for this service, the report category is the directive name undef.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=JC1.22,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=JC1.22,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=JC1.22,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule JC1.23

Summary

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if or #ifdef directive to which they are related. (See page 17 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Rule JC1.24

Summary

There should be no more than one statement or variable declaration per line. A single exception is the C for-loop, where the three controlling expressions (initialization, loop bound, and increment) can be placed on a single line. (See page 17 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option contexts
contexts
-config=JC1.24,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule JC1.25

Summary

Functions should be no longer than 60 lines of text and define no more than 6 parameters. (See page 17 of NASA-JPL-C-2009 [3] .)

Description

Functions longer than 60 lines of code or have more than 6 parameters are reported.

Note that the metrics can be changed using the metric_show service configuration with the metric B.PARAM_FUNC to specify the maximum number of parameters and the metric B.LSLOCS_FUNC to specify the number of lines of code.

Configuration

See generic service options.

Option metric_show
metric_show
-config=JC1.25,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=JC1.25,metric_show={B.PARAM_FUNC, 6}

Option declarations
declarations
-config=JC1.25,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option limit
limit
-config=JC1.25,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=JC1.25,limit=60

Rule JC1.26

Summary

The declaration of an object should contain no more than two levels of indirection. (See page 17 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Rule JC1.27

Summary

Statements should contain no more than two levels of dereferencing per object. (See page 17 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Rule JC1.28

Summary

Pointer dereference operations should not be hidden in macro definitions or inside typedef declarations. (See page 17 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Rule JC1.29

Summary

Non-constant pointers to functions should not be used. (See page 17 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option declarations
declarations
-config=JC1.29,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule JC1.30

Summary

Conversions shall not be performed between a pointer to a function and any type other than an integral type. (See page 17 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option casts
casts
-config=JC1.30,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule JC1.31

Summary

#include directives in a file shall only be preceded by other preprocessor directives or comments. (See page 18 of NASA-JPL-C-2009 [3] .)

Configuration

See generic service options.

Option headers
headers
-config=JC1.31,headers={TAGS, HEADER_MATCHER},...

Specifies report tags for the #include directives.

The configuration’s content is a list of clauses specifying report tags for matching #include names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

HEADER_MATCHER:

the #include argument matcher including quotes or chevrons. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option exception
exception
-config=JC1.31,exception=EXCEPT,...

Specify allowed exceptions to this rule.

{EXCEPT,…}:

allowed exception to this rule. Accepted members are:

  • extern_C: constructs of the form extern "C" {...} are not considered to be code (for ‘C++’ rules);

  • extern_C_only: constructs of the form extern "C" are not considered to be code (for ‘C++’ rules); the following {…} may only contain preprocessor directives;

  • namespace_alias: constructs of the form namespace A = B are not considered to be code;

  • if_directive: directive subsections that are bounded by the #if, #else, #elif and #endif directives are considered as separate code chunks;


The Geotechnical-C++-Style 2011 Rules

Rule KP4.40

Summary

Header files must contain an include guard. (See http://geosoft.no/development/cppstyle.html#Include Files .)

Configuration

See generic service options.

Option directives
directives
-config=KP4.40,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


The JSF Rules

Rule LP1.1

Summary

Any one function (or method) will contain no more than 200 logical source lines of code (L-SLOCs). (See page 11 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option limit
limit
-config=LP1.1,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=LP1.1,limit=200

Option declarations
declarations
-config=LP1.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.3

Summary

All functions shall have a cyclomatic complexity number of 20 or less. (See page 11 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option limit
limit
-config=LP1.3,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=LP1.3,limit=20

Option declarations
declarations
-config=LP1.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.8

Summary

All code shall conform to ISO/IEC 14882:2002(E) standard C++. [2]. (See page 16 of JSF-CPP-2005 [1] .)This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptmarg STD.enumlist STD.extident STD.flexaray STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=LP1.8,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=LP1.8,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=LP1.8,standards=c++03

Rule LP1.11

Summary

Trigraphs will not be used. Trigraph sequences are three-character sequences that are replaced by a corresponding single character, as follows: Alternative Primary alternative primary alternative primary ??= # ??( [ ??< { ??/ \ ??) ] ??> } ??' ^ ??! | ??- ~ The trigraph sequences provide a way to specify characters that are missing on some terminals, but that the C++ language uses. (See page 16 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.12

Summary

The following digraphs will not be used: Alternative Primary alternative Primary <% { :> ] %> } %: # <: [ %:%: ## The digraphs listed above provide a way to specify characters that are missing on some terminals, but that the C++ language uses. (See page 17 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.13

Summary

Multi-byte characters and wide string literals will not be used. (See page 17 of JSF-CPP-2005 [1] .)

Description

Multibyte characters and wide string literals must not be used.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=LP1.13,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule LP1.14

Summary

Literal suffixes shall use uppercase rather than lowercase letters. (See page 17 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option literals
literals
-config=LP1.14,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule LP1.16

Summary

Only DO-178B level A [2] certifiable or SEAL 1 C/C++ libraries shall be used with safety-critical (i.e. SEAL 1) code [2]. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.17

Summary

The error indicator errno shall not be used. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option macros
macros
-config=LP1.17,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=LP1.17,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.18

Summary

The macro offsetof, in library <stddef.h>, shall not be used. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.18,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.18,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.19

Summary

<locale.h> and the setlocale function shall not be used. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.19,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.20

Summary

The setjmp macro and the longjmp function shall not be used. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.20,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.20,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.21

Summary

The signal handling facilities of <signal.h> shall not be used. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.21,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.21,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.22

Summary

The input/output library <stdio.h> shall not be used. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.22,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.22,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.23

Summary

The library functions atof, atoi and atol from library <stdlib.h> shall not be used. (See page 18 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.23,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.24

Summary

The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used. (See page 19 of JSF-CPP-2005 [1] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=LP1.24,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=LP1.24,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.25

Summary

The time handling functions of library <time.h> shall not be used. (See page 19 of JSF-CPP-2005 [1] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.25,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.25,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.26

Summary

Only the following pre-processor directives shall be used:

  1. #ifndef

  2. #define

  3. #endif

  4. #include.

(See page 19 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=LP1.26,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=LP1.26,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=LP1.26,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule LP1.27

Summary

#ifndef, #define and #endif will be used to prevent multiple inclusions of the same header file. Other techniques to prevent the multiple inclusions of header files will not be used. (See page 19 of JSF-CPP-2005 [1] .)

Description

Reports any header file that uses either the ifdef or the pragma mechanisms (i.e., it does not report the header file if there is no mechanism or if it starts with the ifndef mechanism), whereas rule LP1.35 will report any header file that does not use a valid mechanism to prevent multiple inclusions.

Configuration

See generic service options.

Rule LP1.28

Summary

The #ifndef and #endif pre-processor directives will only be used as defined in 4.6.1 to prevent multiple inclusions of the same header file. (See page 19 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=LP1.28,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=LP1.28,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=LP1.28,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule LP1.29

Summary

The #define pre-processor directive shall not be used to create inline macros. Inline functions shall be used instead. (See page 20 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=LP1.29,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=LP1.29,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=LP1.29,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.30

Summary

The #define pre-processor directive shall not be used to define constant values. Instead, the const qualifier shall be applied to variable declarations to specify constant values. (See page 20 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option macros
macros
-config=LP1.30,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.31

Summary

The #define pre-processor directive will only be used as part of the technique to prevent multiple inclusions of the same header file. (See page 20 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=LP1.31,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=LP1.31,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=LP1.31,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule LP1.32

Summary

The #include pre-processor directive will only be used to include header (*.h) files. (See page 20 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=LP1.32,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=LP1.32,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule LP1.33

Summary

The #include directive shall use the <filename.h> notation to include header files. (See page 21 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=LP1.33,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=LP1.33,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule LP1.35

Summary

A header file will contain a mechanism that prevents multiple inclusions of itself. (See page 21 of JSF-CPP-2005 [1] .)

Description

Reports any header file that does not use a valid mechanism to prevent multiple inclusions, whereas rule LP1.27 will report any header file that uses either the ifdef or the pragma mechanisms.

Configuration

See generic service options.

Option directives
directives
-config=LP1.35,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule LP1.39

Summary

Header files (*.h) will not contain non-const variable definitions or function definitions. (See page 22 of JSF-CPP-2005 [1] .)

Description

Reports any non-const variable definitions or function definitions in files that are included via the #include directive.

Exceptions

Inline functions and definitions in the context of a template declaration (class or function) are not reported.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.39,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.41

Summary

Source lines will be kept to a length of 120 characters or less. (See page 22 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.42

Summary

Each expression-statement will be on a separate line. (See page 23 of JSF-CPP-2005 [1] .)

Description

Each expression that is followed by a ; must, apart from comments, be on a line by itself.

Exceptions

An exception is the for statement where only the body has to be on a line by itself.

Configuration

See generic service options.

Option contexts
contexts
-config=LP1.42,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.43

Summary

Tabs should be avoided. (See page 23 of JSF-CPP-2005 [1] .)

Description

The <TAB> character must not be used.

Configuration

See generic service options.

Rule LP1.44

Summary

All indentations will be at least two spaces and be consistent within the same source file. (See page 23 of JSF-CPP-2005 [1] .)

Description

Reports the source lines where the indentation is not a multiple of 2 spaces.

Configuration

See generic service options.

Rule LP1.45

Summary

All words in an identifier will be separated by the _ character. (See page 23 of JSF-CPP-2005 [1] .)

Description

Reports if entity names do not use the defined vocabulary This must be configured with appropriate values; in particular, the context_dictionary service configuration should name a dictionary file.

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=LP1.45,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=LP1.45,project_dictionary=""

Option context_dictionary
context_dictionary
-config=LP1.45,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=LP1.45,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=LP1.45,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=LP1.45,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=LP1.45,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=LP1.45,segmentation_stops_after=none

Option max_no_case_length
max_no_case_length
-config=LP1.45,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=LP1.45,max_no_case_length=16

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=LP1.45,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=LP1.45,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=LP1.45,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=LP1.45,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=LP1.45,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.45,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=LP1.45,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option good_words_file
good_words_file
-config=LP1.45,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=LP1.45,good_words_file=""

Option bad_words_file
bad_words_file
-config=LP1.45,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=LP1.45,bad_words_file=""

Option good_items_file
good_items_file
-config=LP1.45,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=LP1.45,good_items_file=""

Option bad_items_file
bad_items_file
-config=LP1.45,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=LP1.45,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=LP1.45,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=LP1.45,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=LP1.45,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=LP1.45,bad_item_regexs={}

Rule LP1.46

Summary

User-specified identifiers (internal and external) will not rely on significance of more than 64 characters. (See page 23 of JSF-CPP-2005 [1] .)

Description

User-specified identifiers must not rely on the significance of more than 64 characters.

Note that as all identifiers are checked, the rule is more general and more inclusive than the specification in the source file (see page 14 of JSF-C++:2005 [1] , Section 4.3, item 20).

Configuration

See generic service options.

Option identifier_length
identifier_length
-config=LP1.46,identifier_length={SEL, CASE, LEN},...

Specify significant length and case significance for identifiers for selected entities.

The configuration’s content is a list of entity matchers with significant length and case significance.

SEL:

a -entity_selector identifier or a matcher expression used to select the entities.

CASE:

indicate if case is significant. Accepted values are:

  • case_insensitive: case is not significant;

  • case_sensitive: case is significant;

LEN:

length of significant leading part of identifier; 0 indicates that there is no limit. It must be an integer greater than or equal to 0.

Default:

-config=LP1.46,identifier_length={external_and_internal_identifiers, case_sensitive, 64}

Option ignored_decls
ignored_decls
-config=LP1.46,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=LP1.46,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.47

Summary

Identifiers will not begin with the underscore character _. (See page 23 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=LP1.47,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=LP1.47,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=LP1.47,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=LP1.47,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=LP1.47,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.47,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=LP1.47,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule LP1.48

Summary

Identifiers will not differ by:

  • Only a mixture of case

  • The presence/absence of the underscore character

  • The interchange of the letter O, with the number 0 or the letter D

  • The interchange of the letter I, with the number 1 or the letter l

  • The interchange of the letter S with the number 5

  • The interchange of the letter Z with the number 2

  • The interchange of the letter n with the letter h.

(See page 23 of JSF-CPP-2005 [1] .)

Description

Identifiers must be distinct after the following ordered list of replacements:

  • replace h by n,

  • replace D by O,

  • replace 0 by O,

  • replace l by I,

  • replace 1 by I,

  • replace 5 by S,

  • replace 2 by Z,

  • replace all lowercase letters by the corresponding uppercase letters,

  • removal of any underscore characters.

Note that this rule does not check macros or macro parameters (see page 14 of JSF-C++:2005 [1] , Section 4.3, item 20).

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=LP1.48,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=LP1.48,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule LP1.49

Summary

All acronyms in an identifier will be composed of uppercase letters. (See page 24 of JSF-CPP-2005 [1] .)

Description

This must be configured with appropriate values; in particular, the context_dictionary service configuration should name a language dictionary file that includes the acronyms in uppercase.

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=LP1.49,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=LP1.49,project_dictionary=""

Option context_dictionary
context_dictionary
-config=LP1.49,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=LP1.49,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=LP1.49,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=LP1.49,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=LP1.49,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=LP1.49,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=LP1.49,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=LP1.49,max_no_case_length=16

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=LP1.49,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=LP1.49,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=LP1.49,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=LP1.49,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=LP1.49,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.49,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=LP1.49,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option good_words_file
good_words_file
-config=LP1.49,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=LP1.49,good_words_file=""

Option bad_words_file
bad_words_file
-config=LP1.49,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=LP1.49,bad_words_file=""

Option good_items_file
good_items_file
-config=LP1.49,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=LP1.49,good_items_file=""

Option bad_items_file
bad_items_file
-config=LP1.49,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=LP1.49,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=LP1.49,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=LP1.49,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=LP1.49,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=LP1.49,bad_item_regexs={}

Rule LP1.50

Summary

The first word of the name of a class, structure, namespace, enumeration, or type created with typedef will begin with an uppercase letter. All others letters will be lowercase. (See page 24 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=LP1.50,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=LP1.50,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=LP1.50,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=LP1.50,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=LP1.50,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.50,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=LP1.50,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule LP1.51

Summary

All letters contained in function and variable names will be composed entirely of lowercase letters. (See page 25 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=LP1.51,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=LP1.51,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=LP1.51,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=LP1.51,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=LP1.51,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.51,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=LP1.51,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule LP1.52

Summary

Identifiers for constant and enumerator values shall be lowercase. (See page 25 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=LP1.52,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=LP1.52,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=LP1.52,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=LP1.52,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=LP1.52,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=LP1.52,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=LP1.52,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule LP1.53

Summary

Header files will always have a file name extension of “.h”. (See page 25 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=LP1.53,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=LP1.53,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule LP1.53.1

Summary

The following character sequences shall not appear in header file names: `, \, /*, //, or ". (See page 25 of JSF-CPP-2005 [1] .)

Description

To avoid the reporting of \ in file path names, the path_uses_backslash service configuration should be used.

The reports can be tagged using the include_name_exception.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=LP1.53.1,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=LP1.53.1,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule LP1.54

Summary

Implementation files will always have a file name extension of “.cpp”. (See page 26 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.57

Summary

The public, protected, and private sections of a class will be declared in that order (the public section is declared before the protected section which is declared before the private section). (See page 26 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.59

Summary

The statements forming the body of an if, else if, else, while, do...while or for statement shall always be enclosed in braces, even if the braces form an empty block. (See page 27 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.89

Summary

A base class shall not be both virtual and non-virtual in the same hierarchy. (See page 34 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.107

Summary

Functions shall always be declared at file scope. (See page 39 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.107,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.108

Summary

Functions with variable numbers of arguments shall not be used. (See page 39 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.108,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.110

Summary

Functions with more than 7 arguments will not be used. (See page 40 of JSF-CPP-2005 [1] .)

Description

Functions that have more than 7 parameters are reported.

Note that the metric can be changed using the metric_show service configuration with the metric B.PARAM_FUNC.

Configuration

See generic service options.

Option metric_default_fmt
metric_default_fmt
-config=LP1.110,metric_default_fmt=FMT

Specify the default format.

FMT:

the default format (see the -fmt global configuration content, template reprtmtc__id_default_fmt) that should be used if no other format is specified; it has fields:

subject_kind

subject kind;

subject_msg

subject message;

subject_name

subject name;

subject_named

Boolean indicating if the subject has a name;

metric_id

metric identifier;

metric_summary

metric summary;

lower_case_metric_summary

metric summary in lowercase;

context_kind

context kind;

context_name

context name;

context_desc

context description;

report_where

a tag with values incremental or final indicating where the metric is reported;

domain

the environment or entity where the metric is reported;

domain_msg

a message describing the environment or entity where the metric is reported;

limit

the metric limit;

rel

the relation used to compare the limit with the metric value;

good_limit

the metric limit that must not be exceeded;

subject_eq_context

Boolean indicating if the context and subject are the same;

value

the actual value for the metric.

Default:

-config=LP1.110,metric_default_fmt="%{__metric_value_gt_limit_fmt()}"

Option metric_show
metric_show
-config=LP1.110,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=LP1.110,metric_show={B.PARAM_FUNC, 7}

Option declarations
declarations
-config=LP1.110,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.111

Summary

A function shall not return a pointer or reference to a non-static local object. (See page 40 of JSF-CPP-2005 [1] .)

Description

It is shown if a pointer or reference to an object with automatic storage is returned by a function.

Configuration

See generic service options.

Rule LP1.113

Summary

Functions will have a single exit point. (See page 40 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=LP1.113,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=LP1.113,exit_kind={return, only_at_end_position, true},
  {noreturn_call, anywhere, true}

Option end_position
end_position
-config=LP1.113,end_position={{POS,...}, END},...

Specify the end positions and if an exit node is required.

The configuration’s content is a list of the end positions and if a exit kind node is required at that position.

{POS,…}:

end position in the function body. Accepted members are:

  • compound: the end of the body when the body is a compound statement;

  • try: the end of the body when the body is a try block;

  • catch: the end of a catch handler when the body is a try block;

  • compound_try: the end of a try block when last statement of the function body is the try block;

  • compound_catch: the end of a catch handler when last statement of the function body is the handled try block;

END:

whether the exit position must always have an exit kind node. Accepted values are:

  • true: the exit position must always have an exit node;

  • false: the exit position does not have to have an exit node;

Default:

-config=LP1.113,end_position={{compound, try}, false}

Rule LP1.114

Summary

All exit points of value-returning functions shall be through return statements. (See page 40 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.114,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.114,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=LP1.114,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule LP1.115

Summary

If a function returns error information, then that error information will be tested. (See page 40 of JSF-CPP-2005 [1] .)

Description

Calls to standard library functions whose return values contain error information are always checked.

To specify functions not in the standard library that return error information use the -call_properties global configuration with property error.

An error-returning function call is compliant if any of the following hold.

  • The returned value is tested directly and the result of the test is used.

  • The returned value is returned directly to the calling function which must have a similar error value expectation (that is, with the same error configuration).

  • The returned value is stored in a variable and that variable is tested in a statement that immediately follows the call in one of the following ways:

    • the test is in the condition part of an if statement;

    • the variable is in the condition expression of a switch statement, and the case and default labels select the specified error values;

    • it is a return statement that returns the result of the test.

Note that to specify the handling of a function’s error values use the handling service configuration.

Imprecision

False positives are reported because there is no check that the returned value may contain error information.

False negatives are present because it is not checked if the return value is actually tested.

Configuration

See generic service options.

Option calls
calls
-config=LP1.115,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option handling
handling
-config=LP1.115,handling={DECL_MATCHER, ID, SLCT, {{TAG, ACTION, FMT},...}},...

Specify the error handling.

The configuration’s content is an ordered list of a declaration matcher for the calling function, an error identifier and associated data about where the error is placed, where it should be tested and what actions should be taken.

Note that the first matching clause for the calling function and error identifier will be selected and the error value is checked using the associated data

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

ID:

an identifier declared in the -function_error global configuration.

SLCT:

specifies if handling is in a switch or if statement. Accepted values are:

  • any: any selection;

  • if: if statement;

  • switch: switch statement;

TAG:

a value tag declared in the -function_error global configuration.

ACTION:

action to be taken at end of related error branch. Accepted forms are:

  • any: the action is not checked

  • return_any(): the action is to return

  • return(RETURN_VAL): the action is to return RETURN_VAL

  • return_minus(RETURN_VAL): the action is to return the negated RETURN_VAL

  • return_call(CALL_MATCHER,RETURN_VAL): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression) where the RETURN_VAL is an argument to the call; the called function must have a noreturn attribute (see the -decl_properties global configuration)

  • goto(REGEX): the action is a goto statement with label matching REGEX

  • throw(TYPE_MATCHER): the action is a throw statement with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • call(CALL_MATCHER): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression)

  • switch(FUNCTION_ERROR): the action is a switch statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

  • if(FUNCTION_ERROR): the action is an if statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

REGEX

accepted forms are:

RETURN_VAL

accepted forms are:

  • return_value(): the returned value

  • INTEGER: the value

  • STMT_MATCHER: a sub-expression of an expression matching STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template callpost__default_fmt) to specify the message describing ACTION.

Default:

-config=LP1.115,handling={}

Rule LP1.118.1

Summary

An object should be passed as const T* if its value should not be modified. (See page 41 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=LP1.118.1,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=LP1.118.1,show_declarations=all

Option declarations
declarations
-config=LP1.118.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=LP1.118.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=LP1.118.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule LP1.119

Summary

Functions shall not call themselves, either directly or indirectly (i.e. recursion shall not be allowed). (See page 41 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.119,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=LP1.119,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule LP1.121

Summary

Only functions with 1 or 2 statements should be considered candidates for inline functions. (See page 42 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option limit
limit
-config=LP1.121,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=LP1.121,limit=3

Option declarations
declarations
-config=LP1.121,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.124

Summary

Trivial forwarding functions should be inlined. (See page 43 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option limit
limit
-config=LP1.124,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=LP1.124,limit=2

Option declarations
declarations
-config=LP1.124,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.126

Summary

Only valid C++ style comments (//) shall be used. (See page 43 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option comments
comments
-config=LP1.126,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule LP1.127

Summary

Code that is not used (commented out) shall be deleted. (See page 44 of JSF-CPP-2005 [1] .)

Description

Sections of code in the compiled files must not be commented out.

Any non-compiled sources are reported as additional information.

Note that, by default, doxygen comments are ignored; this can be changed using the comments service configuration.

Configuration

See generic service options.

Option comments
comments
-config=LP1.127,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=LP1.127,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=LP1.127,code_lines=0

Option ignored_comments
ignored_comments
-config=LP1.127,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=LP1.127,ignored_comments=__doxygen_comments

Rule LP1.132

Summary

Each variable declaration, typedef, enumeration value, and structure member will be commented. (See page 44 of JSF-CPP-2005 [1] .)

Description

Reports a declaration that does not have an explanatory comment.

Reports any variable, member, enumeration constant or typedef declaration that does not have a comment immediately after the declaration.

The decl_document_selector service configuration can suppress the declarations checked and, for those not suppressed, specify the comment’s expected position relative to the associated declaration.

The selection of explanatory comments depends on two replacers (see the -replacer global configuration):

  • replacer anydecl_comment_repl selects and replaces the single comments that can contribute to the full documentation for the targeted declaration; this has the following options:

    • if the comment’s replacement is open (resp., close) that the comment is interpreted as the start (resp., end) of a block of declarations, and the replaced comment preceding the open comment is taken to be the explanatory comment for all the declarations in the block;

    • if the saved assoc list name (resp., qname) contains the name (resp., qualified name) of a declaration, then the comment is associated with the declaration’s documentation (independently of its position in the source);

  • replacer anydecl_document_repl checks the concatenated replacements from the previous selection with the following option:

    • if the saved assoc list name is non-empty, then the saved list of identifiers must include the targeted declaration’s name.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=LP1.132,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option decl_document_selector
decl_document_selector
-config=LP1.132,decl_document_selector={TAGS, CTXT, DECL, CONSTR, WHERE},...

Specifies the report tags for undocumented declarations.

The configuration’s content is list of tagged declaration and context matchers with indicators.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONSTR:

number and size constraints. Accepted forms are:

  • LIM: number or size constraint

  • LIM&&LIMS: the comments satisfy LIM and LIMS

LIM

accepted forms are:

  • num(EXPR): the minimum number of comments is specified by EXPR

  • size(EXPR): the minimum number of characters in the comments is specified by EXPR

EXPR

accepted forms are:

  • STRING: arithmetic expression whose variables are metrics

WHERE:

specifies where the explanatory comments are supposed to be found. Accepted values are:

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;

  • doxygen: doxygen-style comments;


Option declarations
declarations
-config=LP1.132,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.133

Summary

Every source file will be documented with an introductory comment that provides information on the file name, its contents, and any program-required information (e.g. legal statements, copyright information, etc). (See page 45 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=LP1.133,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule LP1.134

Summary

Assumptions (limitations) made by functions should be documented in the function’s preamble. (See page 45 of JSF-CPP-2005 [1] .)

Description

In the preprocessed sources, reports a function that does not have an explanatory comment.

Reports a function (that is, a function, method, constructor, conversion or destructor) definition that does not have an explanatory comment immediately after the function declarator and before the first {.

Reports any undefined function that has no explanatory comment immediately before the one of its declarations.

Reports any parameter in the definition that is not referred to in the function’s documentation.

The decl_document_selector service configuration can suppress the declarations checked and, for those not suppressed, specify the comment’s expected position relative to an associated declaration.

The selection of explanatory comments depends on two replacers (see the -replacer):

  • replacer function_comment_repl selects and replaces the single comments that can contribute to the full documentation for the targeted declaration; this has the following options:

    • if the comment’s replacement is open (resp., close) that the comment is interpreted as the start (resp., end) of a block of declarations, and the replaced comment preceding the open comment is taken to be the explanatory comment for all the functions declared in the block;

    • if the saved assoc list name (resp., qname) contains the name (resp., qualified name) of a function, then the comment is associated with the function’s documentation (independently of its position in the source);

  • replacer function_document_repl checks the concatenated replacements from the previous selection with the following options:

    • if the saved assoc list name is non-empty, then the saved list of identifiers must include the targeted function’s name.

    • if the saved assoc list param is non-empty, then the saved list of identifiers must include all the targeted function’s parameter names.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=LP1.134,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option decl_document_selector
decl_document_selector
-config=LP1.134,decl_document_selector={TAGS, CTXT, DECL, CONSTR, WHERE},...

Specifies the report tags for undocumented declarations.

The configuration’s content is list of tagged declaration and context matchers with indicators.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONSTR:

number and size constraints. Accepted forms are:

  • LIM: number or size constraint

  • LIM&&LIMS: the comments satisfy LIM and LIMS

LIM

accepted forms are:

  • num(EXPR): the minimum number of comments is specified by EXPR

  • size(EXPR): the minimum number of characters in the comments is specified by EXPR

EXPR

accepted forms are:

  • STRING: arithmetic expression whose variables are metrics

WHERE:

specifies where the explanatory comments are supposed to be found. Accepted values are:

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;

  • doxygen: doxygen-style comments;


Option declarations
declarations
-config=LP1.134,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.135

Summary

Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier. (See page 45 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.136

Summary

Declarations should be at the smallest feasible scope. (See also 4.16). (See page 45 of JSF-CPP-2005 [1] .)

Description

Reports any variable for which one of the following holds:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • it is used in a single file but declared in a different file;

  • its declaration can be moved to the initialization of a for statement.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.136,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=LP1.136,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule LP1.137

Summary

All declarations at file scope should be static where possible. (See page 45 of JSF-CPP-2005 [1] .)

Description

Reports any referenced function or variable that is declared at file scope but not explicitly declared static and for which all references are in the same unit.

More specifically, reports a function or variable if all the following hold:

  • it is referenced;

  • it is declared at file scope;

  • if it is a variable with external linkage, then all references are in the same unit;

  • the declaration or definition is not in a public API file. A file can be declared part of a public API using -public_files;

  • it is not explicitly declared static.

Configuration

See generic service options.

Option definition_in_same_unit
definition_in_same_unit
-config=LP1.137,definition_in_same_unit=BOOL

Specify if the definition must be in the same translation unit as the references.

BOOL

Accepted values are:

  • true: the definition must be in the same translation unit as the references;

  • false: the definition does not have to be in the same translation unit as the references;

Default:

-config=LP1.137,definition_in_same_unit=true

Option declarations
declarations
-config=LP1.137,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.138

Summary

Identifiers shall not simultaneously have both internal and external linkage in the same translation unit. (See page 45 of JSF-CPP-2005 [1] .)

Description

Any variable or function declaration or definition with internal linkage must include the storage class specifier static Notes:

It is not clear from the rule’s summary what should be checked. However, it indicates that this rule corresponds to MISRA Rule 24 on page 36 MISRA-C:1998 [60] (see service MC1.24).

See also page 117 of JSF-C++:2005 [1] , Appendix A.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.138,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.139

Summary

External objects will not be declared in more than one file. (See also 4.7.). (See page 46 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.139,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.140

Summary

The register storage class specifier shall not be used. (See page 46 of JSF-CPP-2005 [1] .)

Description

There must be no use of the register storage class.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.140,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.144

Summary

Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures. (See page 46 of JSF-CPP-2005 [1] .)

Description

For the non-zero initialization of an array or struct, it is reported if braces do not match the structure.

The length of string literals in character array initializers is not checked.

Configuration

See generic service options.

Rule LP1.145

Summary

In an enumerator list, the = construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized. (See page 47 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.145,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.147

Summary

The underlying bit representations of floating point numbers shall not be used in any way by the programmer. (See page 47 of JSF-CPP-2005 [1] .)

Description

There must be no access to an object of floating-point type via a union or via a pointer to a memory area where an object of floating-point type may be stored.

To be more specific, the rule will report:

  1. if there is a type conversion between a pointer to a floating type and a pointer to any different type, with the following exceptions:

    • the conversion is from/to void*,

    • the conversion maps a pointer to (array of) floating type to a pointer to (array of) the same floating type, where the number and size of array constructions may differ;

  2. any object declaration with union type that has a member with floating-point type;

  3. any object declaration with a (possibly recursive) struct type that has a single member with union type and this has a member of floating-point type;

  4. if a union type with a member of floating-point type is referred to by a compound literal expression.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.147,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option casts
casts
-config=LP1.147,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule LP1.149

Summary

Octal constants (other than zero) shall not be used. (See page 47 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option literals
literals
-config=LP1.149,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule LP1.150

Summary

Hexadecimal constants will be represented using all uppercase letters. (See page 48 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option literals
literals
-config=LP1.150,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule LP1.151

Summary

Numeric values in code will not be used; symbolic values will be used instead. (See page 49 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option literals
literals
-config=LP1.151,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule LP1.151.1

Summary

A string literal shall not be modified. (See page 49 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.152

Summary

Multiple variable declarations shall not be allowed on the same line. (See page 49 of JSF-CPP-2005 [1] .)

Description

Each variable declarator must have its own personal declaration.

Configuration

See generic service options.

Rule LP1.153

Summary

Unions shall not be used. (See page 50 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.153,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=LP1.153,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule LP1.154

Summary

Bit-fields shall have explicitly unsigned integral or enumeration types only. (See page 50 of JSF-CPP-2005 [1] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.154,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=LP1.154,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule LP1.155

Summary

Bit-fields will not be used to pack data into a word for the sole purpose of saving space. (See page 50 of JSF-CPP-2005 [1] .)

Description

A bit-field is reported if:

  • it has plain char type,

  • the containing struct mixes bit-fields with non-bit-fields,

  • the containing class mixes bit-fields with non-bit-fields via inheritance.

Notes:

  • for this interpretation of the rule, the checker has exact precision.

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.155,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=LP1.155,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule LP1.157

Summary

The right hand operand of a && or || operator shall not contain side effects. (See page 51 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option effects
effects
-config=LP1.157,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule LP1.158

Summary

The operands of a logical && or || shall be parenthesized if the operands contain binary operators. (See page 51 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=LP1.158,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule LP1.159

Summary

Operators ||, &&, and unary & shall not be overloaded. (See page 51 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.159,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.160

Summary

An assignment expression shall be used only as the expression in an expression statement. (See page 51 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.160,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.160,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.162

Summary

Signed and unsigned values shall not be mixed in arithmetic or comparison operations. (See page 51 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.163

Summary

Unsigned arithmetic shall not be used. (See page 51 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.164

Summary

The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the left-hand operand (inclusive). (See page 51 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.164.1

Summary

The left-hand operand of a right-shift operator shall not have a negative value. (See page 52 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.164.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.164.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.165

Summary

The unary minus operator shall not be applied to an unsigned expression. (See page 52 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.165,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.165,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.166

Summary

The sizeof operator will not be used on expressions that contain side effects. (See page 52 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option effects
effects
-config=LP1.166,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule LP1.167

Summary

The implementation of integer division in the chosen compiler shall be determined, documented and taken into account. (See page 52 of JSF-CPP-2005 [1] .)This service depends upon the configuration of the following ancillary services: STD.divrmsgn

Configuration

See generic service options.

Option behaviors
behaviors
-config=LP1.167,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=LP1.167,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=LP1.167,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule LP1.168

Summary

The comma operator shall not be used. (See page 52 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.168,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.168,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.169

Summary

Pointers to pointers should be avoided when possible. (See page 52 of JSF-CPP-2005 [1] .)

Description

It is shown if any of the following has more than 1 level of pointer indirection:

  • the declared type of an object;

  • the return type of a function;

  • the type of a cast expression;

  • the type name argument to sizeof;

  • the type name argument in a compound literal expression.

Configuration

See generic service options.

Rule LP1.170

Summary

More than 2 levels of pointer indirection shall not be used. (See page 52 of JSF-CPP-2005 [1] .)

Description

It is shown if an expression has more than 2 levels of pointer indirection.

Configuration

See generic service options.

Rule LP1.173

Summary

The address of an object with automatic storage shall not be assigned to an object which persists after the object has ceased to exist. (See page 53 of JSF-CPP-2005 [1] .)

Description

It is shown if the address of an object with automatic storage is assigned to another automatic object of larger scope or to a static object.

Configuration

See generic service options.

Rule LP1.174

Summary

The null pointer shall not be de-referenced. (See page 53 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.176

Summary

A typedef will be used to simplify program syntax when declaring function pointers. (See page 53 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option types
types
-config=LP1.176,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=LP1.176,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.178

Summary

Down casting (casting from base to derived class) shall only be allowed through one of the following mechanism:

  • Virtual functions that act like dynamic casts (most likely useful in relatively simple cases)

  • Use of the visitor (or similar) pattern (most likely useful in complicated cases).

(See page 54 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option casts
casts
-config=LP1.178,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule LP1.179

Summary

A pointer to a virtual base class shall not be converted to a pointer to a derived class. (See page 54 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option casts
casts
-config=LP1.179,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule LP1.181

Summary

Redundant explicit casts will not be used. (See page 55 of JSF-CPP-2005 [1] .)

Description

Reports any use of redundant casts.

Configuration

See generic service options.

Option casts
casts
-config=LP1.181,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule LP1.182

Summary

Type casting from any type to or from pointers shall not be used. (See page 55 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option casts
casts
-config=LP1.182,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule LP1.184

Summary

Floating point numbers shall not be converted to integers unless such a conversion is a specified algorithmic requirement or is necessary for a hardware interface. (See page 55 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option casts
casts
-config=LP1.184,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule LP1.185

Summary

C++ style casts (const_cast, reinterpret_cast and static_cast) shall be used instead of the traditional C-style casts. (See page 55 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option casts
casts
-config=LP1.185,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule LP1.186

Summary

There shall be no unreachable code. (See page 56 of JSF-CPP-2005 [1] .)

Imprecision

False negatives are present because unreachable code is undecidable.

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.186,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_stmts
ignored_stmts
-config=LP1.186,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option statements
statements
-config=LP1.186,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option all_decls
all_decls
-config=LP1.186,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option diagnostics
diagnostics
-config=LP1.186,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule LP1.187

Summary

All non-null statements shall potentially have a side-effect. (See page 56 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.188

Summary

Labels will not be used, except in switch statements. (See page 56 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.188,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.188,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.189

Summary

The goto statement shall not be used. (See page 56 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.189,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.189,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.190

Summary

The continue statement shall not be used. (See page 56 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.190,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.190,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.191

Summary

The break statement shall not be used (except to terminate the cases of a switch statement). (See page 56 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Rule LP1.192

Summary

All if , else if constructs will contain either a final else clause or a comment indicating why a final else clause is not necessary. (See page 56 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option else_empty
else_empty
-config=LP1.192,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=LP1.192,else_empty={missing, __empty_missing_else_comments}, {null, "no comment"}, {empty_compound, __empty_compound_else_comments}

Option ignored_comments
ignored_comments
-config=LP1.192,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule LP1.193

Summary

Every non-empty case clause in a switch statement shall be terminated with a break statement. (See page 57 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option terminals
terminals
-config=LP1.193,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=LP1.193,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=LP1.193,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule LP1.194

Summary

All switch statements that do not intend to test for every enumeration value shall contain a final default clause. (See page 57 of JSF-CPP-2005 [1] .)

Description

Reports any switch statement that does not have a default label

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.194,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.195

Summary

A switch expression will not represent a Boolean value. (See page 57 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option etypes
etypes
-config=LP1.195,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule LP1.196

Summary

Every switch statement will have at least two cases and a potential default. (See page 57 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.196,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.197

Summary

Floating point variables shall not be used as loop counters. (See page 57 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option for_counter
for_counter
-config=LP1.197,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Rule LP1.198

Summary

The initialization expression in a for loop will perform no actions other than to initialize the value of a single for loop parameter. (See page 57 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option for_structure
for_structure
-config=LP1.198,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=LP1.198,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=LP1.198,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule LP1.199

Summary

The increment expression in a for loop will perform no action other than to change a single loop parameter to the next value for the loop. (See page 58 of JSF-CPP-2005 [1] .)

Description

The loop counters are determined using the following criteria.

A loop counter is:

  • a non-global control variable;

  • initialised in first part of the for statement head or initialized prior to the for statement;

  • tested directly in the second part of the for statement head, occurs in a relational or (dis)equality test or directly passed to a function whose return value is converted to a boolean;

  • modified in the third part of the for statement head.

It is reported if:

  • no loop counter is found, or

  • the third expression does not modify a single loop counter.

Configuration

See generic service options.

Option for_parts
for_parts
-config=LP1.199,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule LP1.200

Summary

Null initialize or increment expressions in for loops will not be used; a while loop will be used instead. (See page 58 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option for_structure
for_structure
-config=LP1.200,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Rule LP1.201

Summary

Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop. (See page 58 of JSF-CPP-2005 [1] .)

Description

A for statement loop counter must not be modified in the loop body.

A loop counter is a variable that is modified in the third part of the for statement head.

If it cannot be proved that a numeric loop counter in a for statement is not be modified in the loop body or its address is not taken in the function body, then the loop counter will be reported.

Configuration

See generic service options.

Rule LP1.202

Summary

Floating point variables shall not be tested for exact equality or inequality. (See page 58 of JSF-CPP-2005 [1] .)

Imprecision

False negatives are present because recognising indirect equality and inequality tests is undecidable.

Configuration

See generic service options.

Option statements
statements
-config=LP1.202,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option ignored_stmts
ignored_stmts
-config=LP1.202,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule LP1.204.1

Summary

The value of an expression shall be the same under any order of evaluation that the standard permits. (See page 59 of JSF-CPP-2005 [1] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule LP1.205

Summary

The volatile keyword shall not be used unless directly interfacing with hardware. (See page 59 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option declarations
declarations
-config=LP1.205,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule LP1.206

Summary

Allocation/deallocation from/to the free store (heap) shall not occur after initialization. (See page 59 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=LP1.206,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=LP1.206,extra_statements={}

Option statements
statements
-config=LP1.206,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.206,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.208

Summary

C++ exceptions shall not be used (i.e. throw, catch and try shall not be used.). (See page 59 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option statements
statements
-config=LP1.208,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=LP1.208,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule LP1.209

Summary

The basic types of int, short, long, float and double shall not be used, but specific-length equivalents should be typedef‘d accordingly for each compiler, and these type names used in the code. (See page 60 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option naming
naming
-config=LP1.209,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=LP1.209,naming=lp1

Option declarations
declarations
-config=LP1.209,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=LP1.209,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule LP1.213

Summary

No dependence shall be placed on C++’s operator precedence rules, below arithmetic operators, in expressions. (See page 61 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=LP1.213,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule LP1.215

Summary

Pointer arithmetic will not be used. (See page 61 of JSF-CPP-2005 [1] .)

Configuration

See generic service options.

Option array_arith_exception
array_arith_exception
-config=LP1.215,array_arith_exception=EXCEPT,...

Specify exceptions to the rule.

{EXCEPT,…}:

a set of pointer operations. Accepted members are:

  • array_index_reachable: array indexing when all objects reachable from the indexed expression are declared as arrays;

  • array_index_strict: array indexing when the indexed expression is not declared as an array;

  • array_index: array index;

  • add: + operation;

  • add_assign: += operation;

  • sub: - operation;

  • sub_assign: -= operation;

  • preinc: pre increment;

  • postinc: post increment;

  • predec: pre decrement;

  • postdec: post decrement;

  • incdec: any increment or decrement operation;

  • argument_passing: argument passing;

Default:

-config=LP1.215,array_arith_exception={}

Option declarations
declarations
-config=LP1.215,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


The MISRA C:2012/2023/2025 Coding Guidelines

For the MISRA C:2012 [45], MISRA C:2023 [58] and MISRA C:2025 [59] coding guidelines, the exact definition takes into account all clarifications published in all the amendments and technical corrigenda and the MISRA information and discussion forum.

The MISRA C coding guidelines have undergone several revisions over the years; to support these revisions, several prefixes are defined to identify a specific version of MISRA C. The following prefixes are used to map MISRA C guidelines in each version to the corresponding ECLAIR service:

Mapping of MISRA C guidelines to ECLAIR services

MISRA C edition

ECLAIR service prefix

MISRA C:2012

MC3R0

MISRA C:2012 Amendment 1

MC3A1

MISRA C:2012 Technical Corrigendum 1

MC3C1

MISRA C:2012 Revision 1

MC3R1

MISRA C:2012 Amendment 2

MC3A2

MISRA C:2012 Technical Corrigendum 2

MC3C2

MISRA C:2012 Amendment 3

MC3A3

MISRA C:2012 Amendment 4

MC3A4

MISRA C:2023

MC3R2, MC3

MISRA C:2025

MC4

The prefix MC4 refers to the latest MISRA C edition, and it is the recommended choice for most users.

Note that for each of the supported MISRA C guidelines, the identifier for the corresponding ECLAIR service is obtained by concatenating the prefix of the corresponding MISRA C edition, detailed in the table above, then .D for directives and .R for rules and then the guideline identifier, thereby obtaining, for example: MC3R2.D1.1, MC3R2.R3.2, MC3R2.R10.1, …

Each guideline that is unchanged with respect to previous versions of the MISRA C coding guidelines is an alias of the same ECLAIR service; for this reason, in subsequent sections the name that appears in the table of contents refers to the latest MISRA C document where that guideline has such definition, with aliases for all earlier revisions listed under the Aliases subsection.

Warning

Each guideline shall be used only via one of its aliases during an analysis

$ eclair_env -enable=MC3R1.R10.1 -enable=MC3A2.R10.1 -- gcc -c ~/p.c
WARNING: for internal service id MC3.R10.1.V0, replacing current service alias MC3R1.R10.1 with new MC3A2.R10.1

Note that the page numbers included in the references to MISRA C:2012, MISRA C:2023 and MISRA C:2025 in the ECLAIR service summaries are for the PDF versions of MISRA C:2012 [45] , MISRA C:2023 [58] and MISRA C:2025 [59] respectively.

Directive MC4.D1.1

Aliases

MC3.D1.1, MC3R2.D1.1, MC3A4.D1.1, MC3A3.D1.1, MC3C2.D1.1, MC3A2.D1.1, MC3R1.D1.1, MC3C1.D1.1, MC3A1.D1.1, MC3R0.D1.1

Summary

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood. (See page 29 of MISRA-C-2012 [45] , page 29 of MISRA-C-2012-Revision-1 [51] , page 13 of MISRA-C-2012-Amendment-2 [52] , page 25 of MISRA-C-2023 [58] , page 25 of MISRA-C-2025 [59] .)

Description

Notes:

  • The behavior configuration of the related ancillary services with its associated -doc can be used to specify the behavior and documentation.

  • The behavior_sampling service configuration can be used to specify the number of samples of code to be reported for each item checked; the default value is 1.

  • Compilers can be white-listed using the compilers service configuration.

For example, with the configuration lines:

-tool_tag={any_g,"language(c)&&tool(^gcc[^/]*$) || language(c++)&&tool(^g\\+\\+[^/]*$)"}
-doc="gcc and g++ are compatible compilers respectively for C and C++."
-config=MC4.D1.1,compilers=any_g

all gcc and g++ compilers are taken to be compatible.

Imprecision

Cautions are reported when the behavior cannot be determined and the related ancillary service reports possible non-compliance as a caution.

If there is no documentation for an implementation-defined behavior item and the checker cannot guarantee that the code will not lead to this behavior, the related ancillary service will report it as a caution.

This service depends upon the configuration of the following ancillary services: STD.bitfldby STD.bitfldor STD.bitfldtp STD.bytebits STD.charlcle STD.charmult STD.charppif STD.charppim STD.charsmem STD.charsmap STD.charsobj STD.charsval STD.datetime STD.diagidnt STD.divrmsgn STD.exitstat STD.extinttp STD.execvals STD.feraisex STD.floatcct STD.floatcst STD.floatexc STD.floatiex STD.floatnrw STD.floatrnd STD.floatstd STD.floatunf STD.floatval STD.fltevmth STD.fltevtyp STD.freesten STD.freestlb STD.freestnd STD.getenvfn STD.extidsig STD.nexidsig STD.inclangl STD.inclexpd STD.inclfile STD.inclhead STD.intfloat STD.mainargv STD.maindefn STD.mathrner STD.mathrond STD.multbtid STD.multbtsl STD.objbytes STD.pragmdir STD.pragmfpc STD.pragmfva STD.pragmhdr STD.remquofn STD.setlocle STD.signdint STD.stdmacro STD.stringfy STD.strtwcst STD.strtwcsu STD.volatltp STD.widestng

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC4.D1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC4.D1.1,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option compilers
compilers
-config=MC4.D1.1,compilers=TOOL_MATCHER,...

Specify the tool tags; compilers are taken to be compatible if and only if they have the same tag.

The configuration’s content is a list of tags matching compatible compilers.

TOOL_MATCHER:

a -tool_tag identifier or a matcher expression whose matching compilers are all considered as compatible.


Option behavior_sampling
behavior_sampling
-config=MC4.D1.1,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Directive MC4.D1.2

Aliases

Summary

The use of language extensions should be minimized. (See page 27 of MISRA-C-2025 [59] .)

Description

This service reports any extension to the standard for any non-standard syntax or constraint violation that has been specified using the behavior configuration of the related ancillary services.

In the absence of a specific configuration, most extensions of the applicable language standard will be reported as violations of Rule 1.1.

If it is decided that (some of) these actually refer to supported compiler extensions, then by using the behavior configuration of the related ancillary services, these extensions will be reported by this service, but will not be reported as violations of Rule 1.1.

Consider the following example:

__asm("NOP");

The token __asm, being non-standard for C99, is non-compliant for the ancillary service STD.tokenext and hence is reported as a violation of Rule 1.1 but, as it has not been specified to be an extension, it is not reported by this service.

On the other hand, if we add the service configuration

-doc='See Chapter "Extensions to the C Language Family" of the compiler manual.'
-config=STD.tokenext,behavior={c99, "^.*$", "^_*asm_*$"}

then the code is a specified extension and hence, although it is reported as a violation by this service it is now compliant for Rule 1.1.

Imprecision

Cautions are reported when the use of an extension cannot be determined.

When the use of an extension is undecidable, the related ancillary service will report possible non-compliance as a caution.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.anonstct STD.araystat STD.arayzero STD.arthinvl STD.bincondl STD.bitfwdth STD.bsercheq STD.caseuplw STD.castunon STD.charescp STD.charset STD.charxwde STD.cmntstle STD.cmpdltrl STD.declmixd STD.decltype STD.defined STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.eofnl STD.flexaray STD.fntpqual STD.forhdecl STD.fprscarg STD.fprscfmt STD.funojptr STD.funptrcv STD.hdrexpnd STD.hostmain STD.iddiflkg STD.iddollar STD.implfunc STD.indxcnst STD.indxvltl STD.intconvn STD.intnlobj STD.ipconrep STD.linedir STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macrsynt STD.macrvarg STD.mainrtrn STD.ncstinit STD.negshift STD.nodecltr STD.nonstdc STD.ppcomma STD.prepdirc STD.pteincmp STD.ptrnconv STD.qotemtch STD.qsortord STD.redltype STD.rtrnemty STD.rvalsubs STD.stdcctxt STD.stdcprag STD.stdtypes STD.stmtexpr STD.strincmp STD.strlitrl STD.tokenext STD.vaargast STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC4.D1.2,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Directive MC4.D2.1

Aliases

MC3.D2.1, MC3R2.D2.1, MC3A4.D2.1, MC3A3.D2.1, MC3C2.D2.1, MC3A2.D2.1, MC3R1.D2.1, MC3C1.D2.1, MC3A1.D2.1, MC3R0.D2.1

Summary

All source files shall compile without any compilation errors. (See page 31 of MISRA-C-2012 [45] , page 31 of MISRA-C-2012-Revision-1 [51] , page 27 of MISRA-C-2023 [58] , page 27 of MISRA-C-2025 [59] .)

Description

Any use of the global configuration -compile=nothing (see the -compile) is reported.

The language syntax errors reported by ECLAIR parser are shown by service B.PARSER

Configuration

See generic service options.

Directive MC4.D3.1

Aliases

MC3.D3.1, MC3R2.D3.1, MC3A4.D3.1, MC3A3.D3.1, MC3C2.D3.1, MC3A2.D3.1, MC3R1.D3.1, MC3C1.D3.1, MC3A1.D3.1, MC3R0.D3.1

Summary

All code shall be traceable to documented requirements. (See page 31 of MISRA-C-2012 [45] , page 31 of MISRA-C-2012-Revision-1 [51] , page 27 of MISRA-C-2023 [58] , page 27 of MISRA-C-2025 [59] .)

Description

Here we just describe the main features of ECLAIR’s support for this service. For more information about how this may be integrated into a complete requirements management system see ECLAIR Requirements Management.

The service relies on a number of configuration parameters that define the project’s requirements and how code constructs relate (by means of special comments) to these requirements.

A requirement is a functionality of the software and its coverages are those aspects that directly relate to the code constructs and therefore are amenable to automatic checking.

The requirements are specified using the -requirements global configuration; this associates a requirement set identifier with a set of named requirements and a set of coverages. The coverages are specified using the -requirement_coverages global configuration that associates each coverage with a coverage tag and a (possibly empty) set of constraints.

The actual sets of requirements and coverages that are of interest to (a subset of) the project are specified by the -coverage_target service configuration.

A requirement comment is a comment that contains a coverage tag followed by a requirement identifier (extracted from the source code using the replacer specified by the -requirement_replacer service configuration).

A code construct is any declaration, statement or macro that matches a declaration, statement or macro matcher, specified by the -covering_construct service configuration. It can be associated to a requirement specification by means of one or more preceding comments (i.e., any comment before the code line with no intervening code or preprocessor lines).

ECLAIR will report a violation when a mismatch or an unexpected association is found between the configuration, comments and code constructs. For instance, when:

  • a selected code construct has no preceding comment;

  • a requirement comment does not precede a selected code construct;

  • a selected code construct has no associated requirement comment;

  • a requirement comment has unexpected text between requirement tags (i.e., something that is not a defined requirement identifier);

  • a requirement comment contains a duplicate requirement identifier;

  • the requirement coverage matcher from the -covering_construct service configuration used to select the construct does not match the requirement identifier and coverage tag in the associated requirement comment;

  • there is an inconsistency between requirements associated to selected code constructs for the same entity (e.g. the declaration(s) and the definition of a function).

Information reports are output for each valid requirement comment and its associated code construct.

Example:

The following configuration for -requirements associates the requirement set identifier impl_req to requirements {REQX, REQY} with coverage {IMPLEMENT} and the set identifier test_req to the requirement {REQZ} with coverages {IMPLEMENT, TEST}:

-requirements+={impl_req, {REQX, REQY}, {IMPLEMENT}}
-requirements+={test_req, {REQZ}, {IMPLEMENT, TEST}}

The following configuration for -requirement_coverages global configuration associates each coverage IMPLEMENT to the tag implements and TEST to the tag tests (note that, in both cases, the set of constraints is empty):

-requirement_coverages+={IMPLEMENT, "implements", {}}
-requirement_coverages+={TEST, "tests", {}}

The following configuration for -coverage_target service configuration indicates that code in all source files whose main source file is main.c must cover all the requirements in the requirement set impl_req for coverage IMPLEMENT:

-config=MC4.D3.1,coverage_target={"main(^main\\.c$)", "set(impl_req)&&cov(IMPLEMENT)"}

The following configuration for the -covering_construct service configuration indicates that each function declaration (except for main()) should have a preceding comment that contains a requirement identifier in the set impl_req with coverage IMPLEMENT (and hence tag @implements or \implements):

-config=MC4.D3.1,covering_construct={decl,
   "-^main(.*)$||kind(function)", "set(impl_req)&&cov(IMPLEMENT)"}

The acceptable forms of the requirement comment and how the requirements are extracted is specified using the -requirement_replacer service configuration. While it is possible to customize the extraction process, two templates called doxygen_comment and doxygen_line_comment that support the use of the coverage tags implements, tests and satisfies are available at "install_dir"/share/config/recipes/REQMAN.ecl see (Coverages). The following configuration lines will support the use of this replacer:

-eval_file=""install_dir"/share/config/recipes/REQMAN.ecl"
-config=MC4.D3.1,requirement_replacer+=doxygen_comment

Then assuming the project contains the file main.c:

/**
 * @implements REQX, REQY
 */
int f() {...}

this replacer will extract the tag implements and requirements REQX and REQY. Then ECLAIR, using all the example’s configuration lines shown above, will deduce that the coverage IMPLEMENT for the requirements REQX and REQY is covered by the function f().

Configuration

See generic service options.

Option coverage_target
coverage_target
-config=MC4.D3.1,coverage_target={FRAME_MATCHER, REQCOV_MATCHER},...

Specify the analysis frames and the associated requirement coverage matchers that define the requirements and coverages that need to be fulfilled by the matched frames.

The configuration’s content is a frame matcher with requirement coverage matcher.

FRAME_MATCHER:

a frame matcher. Accepted forms are:

  • [+]AND_MATCHER: the frame matches AND_MATCHER

  • -AND_MATCHER: the frame does not match AND_MATCHER

  • [+]AND_MATCHER||FRAME_MATCHER: either the frame matches AND_MATCHER or it matches FRAME_MATCHER

  • -AND_MATCHER||FRAME_MATCHER: the frame does not match AND_MATCHER but does match FRAME_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the frame matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the frame matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (FRAME_MATCHER): the frame matches FRAME_MATCHER

  • !BASIC_MATCHER: the frame does not match BASIC_MATCHER

  • any(): any frame matches

  • none(): no frame matches

  • target(FILE_MATCHER): the target file matches FILE_MATCHER (see the -file_tag global configuration)

  • main(FILE_MATCHER): the main file matches FILE_MATCHER (see the -file_tag global configuration)

  • kind(FRAME_KIND[||FRAME_KIND]*): the frame has one of the kind FRAME_KINDs

  • std(STD_MATCHER): the unit frame has a standard that matches STD_MATCHER (see the -stds global configuration)

FRAME_KIND

accepted forms are:

  • unit: unit analysis frame

  • program: program analysis frame

  • project: project analysis frame

  • object: object analysis frame

REQCOV_MATCHER:

a requirement-coverage matcher. Accepted forms are:

  • [+]AND_MATCHER: the requirement-coverage matches AND_MATCHER

  • -AND_MATCHER: the requirement-coverage does not match AND_MATCHER

  • [+]AND_MATCHER||REQCOV_MATCHER: either the requirement-coverage matches AND_MATCHER or it matches REQCOV_MATCHER

  • -AND_MATCHER||REQCOV_MATCHER: the requirement-coverage does not match AND_MATCHER but does match REQCOV_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the requirement-coverage matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the requirement-coverage matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (REQCOV_MATCHER): the requirement-coverage matches REQCOV_MATCHER

  • !BASIC_MATCHER: the requirement-coverage does not match BASIC_MATCHER

  • any(): any requirement-coverage matches

  • none(): no requirement-coverage matches

  • set(SET[||SET]*): the requirement set matches one of SET

  • req(REQ[||REQ]*): the requirement matches one of REQ

  • cov(COV[||COV]*): the requirement coverage matches one of COV

  • regex: a regex matching SET/REQ/COV, where SET is a regular expression matching requirement sets (see the -requirements global configuration), REQ is a regular expression matching requirement identifiers and COV is a regular expression matching coverage identifiers (see the -requirement_coverages global configuration)

REGEX

accepted forms are:


Option requirement_replacer
requirement_replacer
-config=MC4.D3.1,requirement_replacer=ID,...

Specify the replacer that will extract a requirement tag and a requirement identifier from a comment (this extracted pair is referred to here as a tagged requirement).

The configuration’s content is a set of replacers to extract tagged requirements.

ID:

a replacer that matches the entire comment string (allowing for any whitespace characters) and extracts the tagged requirements; to save the tags for checking, use save(@0,A) where A specifies an extracted tagged requirement.


Option covering_construct
covering_construct
-config=MC4.D3.1,covering_construct={KIND, NODE_MATCHER, REQCOV_MATCHER},...

Specify the constructs that should have a comment tagged with a requirement identifier.

The configuration’s content is a list of matcher kinds with a matcher to select constructs that should have comments with tagged requirements.

KIND:

matcher kind. Accepted values are:

  • decl: constructs are declarations and the MATCHER is a -decl_selector identifier or a matcher expression used to select the declarations;

  • stmt: constructs are statements and the MATCHER is a -stmt_selector identifier or a matcher expression used to select the statements or the expressions;

  • macro: constructs are macros and the MATCHER is a -macro_selector identifier or a matcher expression used to select the macro;

NODE_MATCHER:

a declaration, statement or macro matcher expression used to select the matching constructs (see the -decl_selector, the -stmt_selector and the -macro_selector global configurations).

REQCOV_MATCHER:

a requirement-coverage matcher. Accepted forms are:

  • [+]AND_MATCHER: the requirement-coverage matches AND_MATCHER

  • -AND_MATCHER: the requirement-coverage does not match AND_MATCHER

  • [+]AND_MATCHER||REQCOV_MATCHER: either the requirement-coverage matches AND_MATCHER or it matches REQCOV_MATCHER

  • -AND_MATCHER||REQCOV_MATCHER: the requirement-coverage does not match AND_MATCHER but does match REQCOV_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the requirement-coverage matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the requirement-coverage matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (REQCOV_MATCHER): the requirement-coverage matches REQCOV_MATCHER

  • !BASIC_MATCHER: the requirement-coverage does not match BASIC_MATCHER

  • any(): any requirement-coverage matches

  • none(): no requirement-coverage matches

  • set(SET[||SET]*): the requirement set matches one of SET

  • req(REQ[||REQ]*): the requirement matches one of REQ

  • cov(COV[||COV]*): the requirement coverage matches one of COV

  • regex: a regex matching SET/REQ/COV, where SET is a regular expression matching requirement sets (see the -requirements global configuration), REQ is a regular expression matching requirement identifiers and COV is a regular expression matching coverage identifiers (see the -requirement_coverages global configuration)

REGEX

accepted forms are:


Option comments
comments
-config=MC4.D3.1,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=MC4.D3.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Directive MC4.D4.1

Aliases

MC3.D4.1, MC3R2.D4.1, MC3A4.D4.1, MC3A3.D4.1, MC3C2.D4.1, MC3A2.D4.1, MC3R1.D4.1, MC3C1.D4.1, MC3A1.D4.1, MC3R0.D4.1

Summary

Run-time failures shall be minimized. (See page 32 of MISRA-C-2012 [45] , page 32 of MISRA-C-2012-Revision-1 [51] , page 13 of MISRA-C-2012-Amendment-2 [52] , page 28 of MISRA-C-2023 [58] , page 28 of MISRA-C-2025 [59] .)

Description

The document service configuration should be used to specify, for each unexpected behavior kind, where the documenting comment will be found and the expected format.

The behavior kinds that are checked for documentation are:

  • overflow,

  • unexpected wrapping,

  • invalid shift,

  • division/remainder by zero,

  • unsequenced side effects,

  • read from uninitialized automatic object,

  • read from uninitialized allocated object,

  • write to string literal or const object,

  • non-volatile access to volatile object,

  • access to dead allocated object,

  • access to dead automatic object,

  • access to dead thread object,

  • access using null pointer,

  • access using invalid pointer,

  • access using out-of-bounds pointer,

  • access using unaligned pointer,

  • mistyped access to object,

  • mistyped access to function,

  • invalid pointer arithmetic,

  • invalid pointer comparison,

  • overlapping copy,

  • invalid arguments to function,

  • returned function error,

  • tainted input,

  • data race,

  • invariant violation,

  • communication error.

Using the default value for document valid documentation comments look like:

/* Documentation for MISRA C:2012 Dir 4.1: overflow ... To Be Written ... */
/* Documentation for MISRA C:2012 Dir 4.1: invalid shift ... To Be Written ... */
/* Documentation for MISRA C:2012 Dir 4.1: division/remainder by zero ... To Be Written ... */
/* ... */
/* Documentation for MISRA C:2012 Dir 4.1: communication error ... To Be Written ... */

These special comments should be placed in a compiled file, otherwise, ECLAIR will not be able to detect them. For each of them the ... To Be Written ... should be replaced with the description of what is done to minimize the risk or why the situation cannot happen or is not relevant for the project.

Configuration

See generic service options.

Option document
document
-config=MC4.D4.1,document={ID_FMT, SUB, FILE_MATCHER, WHAT, DOC_FMT, REP_FMT},...

Specify how to extrapolate the required documentation from comments in the specified compiled source files.

The configuration’s content is a list of tuples that provide (in order) a unique identifier for the document, context and file matcher indicating where to search for the document, what to check for (e.g., missing documentation), a format for matcher to check the documentation content and a format for the reports.

ID_FMT:

format (see the -fmt global configuration content, template userdocs__id_default_fmt) for short but unique name to identify the document with field:

service

service name.

SUB:

tag indicating subject. Accepted values are:

  • unit: check all files for each translation unit;

  • file: check each file;

  • program: check all the program files;

  • project: check all the project files;

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

WHAT:

tag indicating what to report. Accepted values are:

  • duplicates: report if more than one matching document is found;

  • missing: report if no documentation is found;

  • missing_if_noted: report if no documentation is found and uses are noted;

  • all: report any duplicated or missing documentation;

  • none: do not report missing or duplicated documentation;

DOC_FMT:

format (see the -fmt global configuration content, template userdocs__document_default_fmt) specifying regular expression to match the document content with fields:

document_id

a document identifier;

file

canonical pathname;

rule

rule description;

service

service name.

REP_FMT:

format (see the -fmt global configuration content, template userdocs__default_fmt) for message to be included in the report with fields:

document_id

a document identifier;

file

canonical pathname;

error

message indicating the error kind which can be missing_file, missing_docs or duplicate_docs;

target

unit, program or project description;

service

service name.

Default:

-config=MC4.D4.1,document={"%{__overflow_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__wrapping_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__shift_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__division_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__side_effects_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__write_to_const_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__non_volatile_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_thread_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__null_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__bounds_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__unaligned_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_object_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_function_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_arith_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_compare_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__overlap_copy_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_fun_args_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__return_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__tainted_input_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__data_race_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invariant_viol_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__comms_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"}

Option ignored_comments
ignored_comments
-config=MC4.D4.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Directive MC4.D4.2

Aliases

MC3.D4.2, MC3R2.D4.2, MC3A4.D4.2, MC3A3.D4.2, MC3C2.D4.2, MC3A2.D4.2, MC3R1.D4.2, MC3C1.D4.2, MC3A1.D4.2, MC3R0.D4.2

Summary

All usage of assembly language should be documented. (See page 34 of MISRA-C-2012 [45] , page 34 of MISRA-C-2012-Revision-1 [51] , page 30 of MISRA-C-2023 [58] , page 30 of MISRA-C-2025 [59] .)

Description

Assembly code can be documented by:

  • including a comment before or on the same line as the asm statement;

  • including a comment immediately before a function definition that contains only asm statements (after any macro expansion);

  • including a comment immediately before a macro definition where the body contains only asm statements;

  • including a comment immediately before a loop idiom where the body of the loop contains only asm statements.

Notes:

  • The comment must match the replacer asm_comment_repl; the default value for this replacer will match any comment but this can be changed using the -replacer global configuration.

  • By default, expressions expanded from a macro-defined do-while-zero loop idiom are considered to be loop idioms. This default can be changed using the -loop_idioms global configuration.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MC4.D4.2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_stmts
ignored_stmts
-config=MC4.D4.2,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Directive MC4.D4.3

Aliases

MC3.D4.3, MC3R2.D4.3, MC3A4.D4.3, MC3A3.D4.3, MC3C2.D4.3, MC3A2.D4.3, MC3R1.D4.3, MC3C1.D4.3, MC3A1.D4.3, MC3R0.D4.3

Summary

Assembly language shall be encapsulated and isolated. (See page 34 of MISRA-C-2012 [45] , page 34 of MISRA-C-2012-Revision-1 [51] , page 13 of MISRA-C-2012-Amendment-2 [52] , page 30 of MISRA-C-2023 [58] , page 30 of MISRA-C-2025 [59] .)

Description

A function is non-compliant if it contains an unencapsulated asm statement and a non-asm statement Notes:

  • Expressions and statements specified using the configuration parameters ignored_stmts service configurations are said to be ignored.

  • A macro that contains, other than ignored code, only asm statements is considered a valid asm encapsulator.

  • A function that contains, other than ignored code, only asm statements, possibly expanded from asm encapsulator macros, or calls to asm encapsulator functions is considered a valid asm encapsulator.

  • Any asm statements that are expanded from a macro or in a macro-defined do-while-zero loop idiom are ignored.

Configuration

See generic service options.

Option ignored_stmts
ignored_stmts
-config=MC4.D4.3,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Directive MC4.D4.4

Aliases

MC3.D4.4, MC3R2.D4.4, MC3A4.D4.4, MC3A3.D4.4, MC3C2.D4.4, MC3A2.D4.4, MC3R1.D4.4, MC3C1.D4.4, MC3A1.D4.4, MC3R0.D4.4

Summary

Sections of code should not be “commented out”. (See page 35 of MISRA-C-2012 [45] , page 35 of MISRA-C-2012-Revision-1 [51] , page 31 of MISRA-C-2023 [58] , page 31 of MISRA-C-2025 [59] .)

Description

Any non-compiled sources are reported as additional information.

Note that, by default, doxygen comments are ignored; this can be changed using the ignored_comments service configuration. For example, with the following configure line, all comments will be checked:

-doc="Prevent doxygen comments from being ignored."
-config=MC4.D4.4,+ignored_comments="none()"

Implementation

A comment is non-compliant if it looks like code. That is, a comment is reported if a statistical measure (based on the total token length and number of keywords and operators) is exceeded.

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

It is not possible to precisely differentiate code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

/* This is a comment */

Configuration

See generic service options.

Option comments
comments
-config=MC4.D4.4,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=MC4.D4.4,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=MC4.D4.4,code_lines=0

Option ignored_comments
ignored_comments
-config=MC4.D4.4,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC4.D4.4,ignored_comments=__doxygen_comments

Directive MC4.D4.5

Aliases

MC3.D4.5, MC3R2.D4.5, MC3A4.D4.5, MC3A3.D4.5, MC3C2.D4.5, MC3A2.D4.5, MC3R1.D4.5, MC3C1.D4.5, MC3A1.D4.5, MC3R0.D4.5

Summary

Identifiers in the same name space with overlapping visibility should be typographically unambiguous. (See page 35 of MISRA-C-2012 [45] , page 35 of MISRA-C-2012-Revision-1 [51] , page 31 of MISRA-C-2023 [58] , page 31 of MISRA-C-2025 [59] .)

Description

Identifiers are typographically ambiguous if the following character replacements (done in the specified order) result in identical strings:

  1. removal of any underscore character;

  2. replacement of 0 by O;

  3. replacement of 1 by I;

  4. replacement of l by I;

  5. replacement of 5 by S;

  6. replacement of 2 by Z;

  7. replacement of h by n;

  8. replacement of 8 by B;

  9. replacement of m by rn;

  10. replacement of lowercase letters by uppercase.

This is the default specification. If intended meaning of typographically ambiguous in the context of a specific project differs from the default, it can be specified using the similar_map service configuration, where the identifiers for the pairs of entity or macro identifiers to be compared are:

  • introduces_id_entity (for comparing an entity identifier with other entity identifiers or macro names)

  • and macro_entity (for comparing a macro name with the names of its parameters).

For example, the following configuration is similar to the default except it does not replace m by rn but does replace 4 by T:

-config=MC4.D4.5,!similar_map=
{introduces_id_entity, "tr('01l52h84_','OIISZnBT')||upcase"},
{macro_entity, "tr('01l52h84_','OIISZnBT')||upcase"}

Configuration

See generic service options.

Option similar_map
similar_map
-config=MC4.D4.5,similar_map={MATCH_ID, MAPPING},...

Specify mappings of identifiers to their canonical form.

The configuration’s content is a list of identifier mappings.

MATCH_ID:

the identifier for the selected entities.

MAPPING:

. Accepted forms are:

  • std(REGEX): matches a service

  • min(NUMBER,CASE): the identifier prefix of length NUMBER, (after convertion to upper-case, if CASE is case_insensitive), is the canonical form

  • REPLACER[||REPLACER]*): a list of alternative REPLACERs (see the -replacer global configuration) defining the replacements that map the identifier to its canonical forms

CASE

accepted forms are:

  • case_sensitive: the identifier is case-sensitive

  • case_insensitive: the identifier is case-insensitive and the canonical form has all letters converted to upper-case

Default:

-config=MC4.D4.5,similar_map={introduces_id_entity, "replace('m','rn')|tr('01l52h8','OIISZnB')||tr('_','')|upcase"},
  {macro_entity, "replace('m','rn')|tr('01l52h8','OIISZnB')||tr('_','')|upcase"}

Option ignored_decls
ignored_decls
-config=MC4.D4.5,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC4.D4.5,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Directive MC3C2.D4.6

Aliases

MC3A2.D4.6, MC3R1.D4.6, MC3C1.D4.6, MC3A1.D4.6, MC3R0.D4.6

Summary

typedefs that indicate size and signedness should be used in place of the basic numerical types. (See page 36 of MISRA-C-2012 [45] , page 7 of MISRA-C-2012-TC1 [48] , page 36 of MISRA-C-2012-Revision-1 [51] , page 13 of MISRA-C-2012-Amendment-2 [52] .)

Description

The rule assumes the proposal for the typedef names in the normative text of the MISRA C document as the default schema; the typedef name is non-compliant if it does not have one of the following forms (where @BITS@ is replaced by the length in bits):

  • signed integer type - int@BITS@_t,

  • unsigned integer type - uint@BITS@_t,

  • floating type - float@BITS@_t.

The naming service configuration can be used to change the schema.

Configuration

See generic service options.

Option naming
naming
-config=MC3C2.D4.6,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MC3C2.D4.6,naming=misra

Option declarations
declarations
-config=MC3C2.D4.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC3C2.D4.6,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Directive MC3.D4.6

Aliases

MC3R2.D4.6, MC3A4.D4.6, MC3A3.D4.6

Summary

typedefs that indicate size and signedness should be used in place of the basic numerical types. (See page 11 of MISRA-C-2012-Amendment-3 [55] , page 33 of MISRA-C-2023 [58] , page 33 of MISRA-C-2025 [59] .)

Description

The rule assumes the proposal for the typedef names in the normative text of the MISRA C document as the default schema; the typedef name is non-compliant if it does not have one of the following forms (where @BITS@ is replaced by the length in bits):

  • signed integer type - int@BITS@_t,

  • unsigned integer type - uint@BITS@_t,

  • floating type - float@BITS@_t,

  • complex floating type - cfloat@BITS@_t.

The naming service configuration can be used to change the schema.

Configuration

See generic service options.

Option naming
naming
-config=MC3.D4.6,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MC3.D4.6,naming=misra

Option declarations
declarations
-config=MC3.D4.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC3.D4.6,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Directive MC4.D4.6

Aliases

Summary

typedefs that indicate size and signedness should be used in place of the basic numerical types. (See page 33 of MISRA-C-2025 [59] .)

Description

The rule assumes the proposal for the typedef names in the normative text of the MISRA C document as the default schema; the typedef name is non-compliant if it does not have one of the following forms (where @BITS@ is replaced by the length in bits):

  • signed integer type - int@BITS@_t,

  • unsigned integer type - uint@BITS@_t,

The naming service configuration can be used to change the schema.

Configuration

See generic service options.

Option naming
naming
-config=MC4.D4.6,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MC4.D4.6,naming=misra

Option declarations
declarations
-config=MC4.D4.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC4.D4.6,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Directive MC4.D4.7

Aliases

MC3.D4.7, MC3R2.D4.7, MC3A4.D4.7, MC3A3.D4.7, MC3C2.D4.7, MC3A2.D4.7, MC3R1.D4.7, MC3C1.D4.7, MC3A1.D4.7, MC3R0.D4.7

Summary

If a function returns error information, then that error information shall be tested. (See page 38 of MISRA-C-2012 [45] , page 38 of MISRA-C-2012-Revision-1 [51] , page 34 of MISRA-C-2023 [58] , page 34 of MISRA-C-2025 [59] .)

Description

Calls to standard library functions whose return values contain error information are always checked.

To specify functions not in the standard library that return error information use the -call_properties global configuration with property error.

An error-returning function call is compliant if any of the following hold.

  • The returned value is tested directly and the result of the test is used.

  • The returned value is returned directly to the calling function which must have a similar error value expectation (that is, with the same error configuration).

  • The returned value is stored in a variable and that variable is tested in a statement that immediately follows the call in one of the following ways:

    • it is an if statement and the test is in the condition part;

    • it is an assign operator where the right-hand side is a conditional operator ?: and the test is in the condition part;

    • it is a switch statement, the variable reference is the condition expression and the case and default labels select the specified error values;

    • it is a return statement that returns the variable.

Note that to specify the handling of a function’s error values use the handling service configuration.

For example, the configuration line:

-doc="The return value of functions matching __return_cast_minusone_errors must be assigned to a variable whose name starts with time_, then verified and returned."
-config=MC4.D4.7,handling+={"any()", __return_cast_minusone_errors,
if, {{return_cast_minusone_tag, "return(ref(^(time_).*$))", ""}}}

specifies that for any called function with an error property that matches the selector __return_minusone_errors, (this is a builtin selector for the -function_error global configuration, that requires the error value, returned by the called function, to be -1), then:

  • the return value must be assigned to a variable that matches ^(time_).*$,

  • the variable must be tested in the condition part of an if statement and

  • returned by the calling function.

If the handling for the function error is not specified, then there is no check on any action taken when an error value is returned.

Configuration

See generic service options.

Option calls
calls
-config=MC4.D4.7,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option handling
handling
-config=MC4.D4.7,handling={DECL_MATCHER, ID, SLCT, {{TAG, ACTION, FMT},...}},...

Specify the error handling.

The configuration’s content is an ordered list of a declaration matcher for the calling function, an error identifier and associated data about where the error is placed, where it should be tested and what actions should be taken.

Note that the first matching clause for the calling function and error identifier will be selected and the error value is checked using the associated data

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

ID:

an identifier declared in the -function_error global configuration.

SLCT:

specifies if handling is in a switch or if statement. Accepted values are:

  • any: any selection;

  • if: if statement;

  • switch: switch statement;

TAG:

a value tag declared in the -function_error global configuration.

ACTION:

action to be taken at end of related error branch. Accepted forms are:

  • any: the action is not checked

  • return_any(): the action is to return

  • return(RETURN_VAL): the action is to return RETURN_VAL

  • return_minus(RETURN_VAL): the action is to return the negated RETURN_VAL

  • return_call(CALL_MATCHER,RETURN_VAL): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression) where the RETURN_VAL is an argument to the call; the called function must have a noreturn attribute (see the -decl_properties global configuration)

  • goto(REGEX): the action is a goto statement with label matching REGEX

  • throw(TYPE_MATCHER): the action is a throw statement with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • call(CALL_MATCHER): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression)

  • switch(FUNCTION_ERROR): the action is a switch statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

  • if(FUNCTION_ERROR): the action is an if statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

REGEX

accepted forms are:

RETURN_VAL

accepted forms are:

  • return_value(): the returned value

  • INTEGER: the value

  • STMT_MATCHER: a sub-expression of an expression matching STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template callpost__default_fmt) to specify the message describing ACTION.

Default:

-config=MC4.D4.7,handling={}

Directive MC4.D4.8

Aliases

MC3.D4.8, MC3R2.D4.8, MC3A4.D4.8, MC3A3.D4.8, MC3C2.D4.8, MC3A2.D4.8, MC3R1.D4.8, MC3C1.D4.8, MC3A1.D4.8, MC3R0.D4.8

Summary

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden. (See page 38 of MISRA-C-2012 [45] , page 7 of MISRA-C-2012-TC1 [48] , page 38 of MISRA-C-2012-Revision-1 [51] , page 35 of MISRA-C-2023 [58] , page 35 of MISRA-C-2025 [59] .)

Description

Note that, if the complete definition of a struct or union is not needed, it should be replaced by a forward declaration.

Configuration

See generic service options.

Directive MC4.D4.9

Aliases

MC3.D4.9, MC3R2.D4.9, MC3A4.D4.9, MC3A3.D4.9, MC3C2.D4.9, MC3A2.D4.9, MC3R1.D4.9, MC3C1.D4.9, MC3A1.D4.9, MC3R0.D4.9

Summary

A function should be used in preference to a function-like macro where they are interchangeable. (See page 39 of MISRA-C-2012 [45] , page 39 of MISRA-C-2012-Revision-1 [51] , page 13 of MISRA-C-2012-Amendment-2 [52] , page 12 of MISRA-C-2012-Amendment-3 [55] , page 36 of MISRA-C-2023 [58] , page 36 of MISRA-C-2025 [59] .)

Description

A function-like macro in the non-skipped compiled sources is considered replaceable by a function call if none of the following hold:

  • one of the macro invocation’s arguments is not expanded to an expression or it is expanded to an expression that cannot be interpreted as an rvalue (and hence cannot be used as a function call argument);

  • the macro body’s text contains special tokens (e.g. __LINE__, __FILE__, __COUNTER_, #, ##);

  • the macro is in a context that is not supported by the standard for including function calls;

  • the macro expands a non-replaceable macro;

  • the macro is used to emulate a template in C;

  • it is a system macro.

Imprecision

False positives are reported when criteria have not been precisely determined.

Criteria such as the trade-off between code size and execution speed are not considered.

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=MC4.D4.9,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=MC4.D4.9,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=MC4.D4.9,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Directive MC4.D4.10

Aliases

MC3.D4.10, MC3R2.D4.10, MC3A4.D4.10, MC3A3.D4.10, MC3A2.D4.10, MC3C2.D4.10, MC3R1.D4.10, MC3C1.D4.10, MC3A1.D4.10, MC3R0.D4.10

Summary

Precautions shall be taken in order to prevent the contents of a header file being included more than once. (See page 40 of MISRA-C-2012 [45] , page 40 of MISRA-C-2012-Revision-1 [51] , page 8 of MISRA-C-2012-TC2 [54] , page 37 of MISRA-C-2023 [58] , page 37 of MISRA-C-2025 [59] .)

Description

Note that this applies to any included file regardless of the file name extension.

Such a file must use one of the mechanisms: ifndef, ifdef and pragma where these are defined by the forms:

  • ifndef

#ifndef Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
#if !defined Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
  • ifdef

#ifdef Guard_Id
#else
#define Guard_Id ...
...
#endif
#if defined Guard_Id
#else
#define Guard_Id ...
...
#endif
  • pragma

#pragma first

It is also shown if the guard’s macro name is used elsewhere in any #define or #undef in the project.

There are no checks on the form or syntax of the macro name.

Configuration

See generic service options.

Option guard
guard
-config=MC4.D4.10,guard={FILE, {CHECK,...}},...

Specify the allowed mechanisms to prevent the contents of a header file being included twice using advanced features.

The configuration’s content is an ordered list of file selectors with conditions; the conditions in the first clause whose file selector matches the file are checked.

FILE:

a -file_tag identifier or a matcher expression used to select the files.

CHECK

Accepted forms are:

  • mechanism(MECHANISM[||MECHANISM]*): the guard’s mechanism

  • guard(GUARD): the file name replacer REPLACER (see the -replacer global configuration). The input provided to the replacer is the canonical pathname of the guarded file; the macro name must match exactly, or must match the regular expression defined by FMT

  • comment(COMMENT_MATCHER): it will be reported if there is no matching comment following the #endif

  • reuse(REUSE_TAG): tag indicating if what reuse of the macro name should be reported

  • regex(): the replaced name is a regular expression that must match the macro guard name

REUSE_TAG

accepted forms are:

  • all_code: it is reported if the same guard identifier is reused for an identifier anywhere in the project code

  • all_defined: it is reported if the same guard identifier is redefined or undefined anywhere in the project

  • all_guards_in_unit: it is reported if the same guard identifier is used for more than one header file in the translation unit

  • all_guards_in_project: it is reported if the same guard identifier is used for more than one header file in the project

MECHANISM

accepted forms are:

  • any: any mechanism

  • ifndef: the guard mechanism using #ifndef Guard_Id or if !defined Guard_Id

  • ifdef: the mechanism using #if defined Guard_Id

  • pragma: the mechanism #pragma once

Default:

-config=MC4.D4.10,guard={^.*$,
    {"mechanism(any)",
      "reuse(all_defined)"}}

Option directives
directives
-config=MC4.D4.10,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Directive MC4.D4.11

Aliases

MC3.D4.11, MC3R2.D4.11, MC3A4.D4.11, MC3A3.D4.11, MC3C2.D4.11, MC3A2.D4.11, MC3R1.D4.11, MC3C1.D4.11, MC3A1.D4.11, MC3R0.D4.11

Summary

The validity of values passed to library functions shall be checked. (See page 41 of MISRA-C-2012 [45] , page 7 of MISRA-C-2012-TC1 [48] , page 41 of MISRA-C-2012-Revision-1 [51] , page 12 of MISRA-C-2012-Amendment-3 [55] , page 38 of MISRA-C-2023 [58] , page 38 of MISRA-C-2025 [59] .)

Implementation

Reports if specified arguments of calls to the standard library functions have not been validated.

An argument is taken to be validated if it is a constant expression or it is a variable and:

  • it occurs in an assertion prior to the function call in the context of a selection, iteration or block node;

  • the call is in a then or else branch of an if statement or the body of a while or for statement and the variable occurs in the condition part;

  • as in the previous case, but in a conditional operator expression.

Constant expressions are validated against the function’s requirements.

Imprecision

False negatives are present because not all functions’ requirements are checked.

Configuration

See generic service options.

Directive MC4.D4.12

Aliases

MC3.D4.12, MC3R2.D4.12, MC3A4.D4.12, MC3A3.D4.12, MC3C2.D4.12, MC3A2.D4.12, MC3R1.D4.12, MC3C1.D4.12, MC3A1.D4.12, MC3R0.D4.12

Summary

Dynamic memory allocation shall not be used. (See page 42 of MISRA-C-2012 [45] , page 42 of MISRA-C-2012-Revision-1 [51] , page 39 of MISRA-C-2023 [58] , page 39 of MISRA-C-2025 [59] .)

Description

Any use of functions that have the malloc property are reported

By default a function has the malloc property if:

  • the function has the attribute malloc;

  • it is one of the standard library functions malloc, calloc, realloc, aligned_alloc, free, strdup, operator new and operator delete.

Additional functions can be assigned the property malloc using the -call_properties global configuration. For example, the following configuration declares that any function whose identifier has the suffix _m has the property malloc:

-call_properties+={"decl(^.*_m\\(.*$)", {malloc}}

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=MC4.D4.12,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=MC4.D4.12,extra_statements={}

Option statements
statements
-config=MC4.D4.12,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.D4.12,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Directive MC4.D4.13

Aliases

MC3.D4.13, MC3R2.D4.13, MC3A4.D4.13, MC3A3.D4.13, MC3C2.D4.13, MC3A2.D4.13, MC3R1.D4.13, MC3C1.D4.13, MC3A1.D4.13, MC3R0.D4.13

Summary

Functions which are designed to provide operations on a resource should be called in an appropriate sequence. (See page 43 of MISRA-C-2012 [45] , page 43 of MISRA-C-2012-Revision-1 [51] , page 40 of MISRA-C-2023 [58] , page 40 of MISRA-C-2025 [59] .)

Description

To specify the resource properties for the called functions use the -call_properties global configuration with property resource.

Imprecision

All functions that use a resource are reported as cautions.

Configuration

See generic service options.

Option calls
calls
-config=MC4.D4.13,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.D4.13,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Directive MC4.D4.14

Aliases

MC3.D4.14, MC3R2.D4.14, MC3A4.D4.14, MC3A3.D4.14, MC3C2.D4.14, MC3A2.D4.14, MC3C1.D4.14, MC3R1.D4.14, MC3A1.D4.14

Summary

The validity of values received from external sources shall be checked. (See page 9 of MISRA-C-2012-Amendment-1 [46] , page 44 of MISRA-C-2012-Revision-1 [51] , page 41 of MISRA-C-2023 [58] , page 41 of MISRA-C-2025 [59] .)

Description

Notes:

  • By default, all the call arguments of functions and macros in the standard library that receive values from external sources are checked.

  • Other function and macro call arguments that should be checked can be specified using the argument_post_select service configuration.

  • The argument_post_select service configuration includes an identifier that should be used by the argument_post_check service configuration to specify the checking mechanism via a statement matcher.

  • For example in the default values for argument_post_select service configuration, a function call to fread (selected by the selector __fread_calls has the call argument range identifier input_args. To specify how the second argument should be checked, add a configure line to the argument_post_check service configuration such as:

-doc="check_array is used to check the values reiceved from some library functions."
-config=MC4.D4.14,+argument_post_check={input_args, "call(decl(name(check_array)))"}

With this configure line, the code

return fread(buf, 1, nbytes, file);
check_array(buf);

will be compliant.

  • Any function or macro call argument will be reported if:

    • the configure line for its associated call argument identifier in the argument_post_check service configuration has a statement matcher that does not match the following statement;

    • there is no configure line for a call argument identifier in the argument_post_check service configuration.

Imprecision

False positives are reported because the recommended constraints may more than cover the user’s requirements.

False negatives are present because the constraints on the use of a variable are undecidable.

Configuration

See generic service options.

Option argument_post_select
argument_post_select
-config=MC4.D4.14,argument_post_select={CALL_MATCHER, RANGE, ID},...

Specify a call matcher and the arguments to be checked with an associated identifier.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.

RANGE:

call argument-range: the range of argument indices to be checked. Accepted forms are:

  • POS_MIN_MAX

ID:

call argument-range identifier.

Default:

-config=MC4.D4.14,argument_post_select={__recv_calls, 2, input_args},
  {__recvfrom_calls, 2, input_args},
  {__recvmsg_calls, 2, input_args},
  {__getpass_calls, 0, return_val},
  {__fgetc_fgetwc_calls, 0, return_val},
  {__fgets_fgetws_calls, 0..1, return_val},
  {__getc_getwc_calls, 0, return_val},
  {__gets_getws_calls, 0..1, input_args},
  {__getchar_getwchar_calls, 0, return_val},
  {__fscanf_fwscanf_calls, 3.., input_args},
  {__scanf_wscanf_calls, 2.., input_args},
  {__sscanf_swscanf_calls, 3.., input_args},
  {__vfscanf_vfwscanf_calls, 3.., input_args},
  {__vscanf_vwscanf_calls, 2.., input_args},
  {__vsscanf_vswscanf_calls, 3.., input_args},
  {__fread_calls, 1, input_args}

Option argument_post_check
argument_post_check
-config=MC4.D4.14,argument_post_check={ID, STMT_MATCHER},...

Specify the statement matchers used to check the call argument-ranges defined by the identifiers.

ID:

call argument-range identifier.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the test statements.statement matcher.

Default:

-config=MC4.D4.14,argument_post_check={}

Option calls
calls
-config=MC4.D4.14,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Directive MC4.D4.15

Aliases

MC3.D4.15, MC3R2.D4.15, MC3A4.D4.15, MC3A3.D4.15

Summary

Evaluation of floating-point expressions shall not lead to the undetected generation of infinities and NaNs. (See page 13 of MISRA-C-2012-Amendment-3 [55] , page 42 of MISRA-C-2023 [58] , page 42 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported when the analysis cannot exclude that the result of an operation or a function applied to ordinary real numbers is NaN or infinity

Configuration

See generic service options.

Option statements
statements
-config=MC4.D4.15,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.D4.15,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option calls
calls
-config=MC4.D4.15,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Directive MC4.D5.1

Aliases

MC3.D5.1, MC3R2.D5.1, MC3A4.D5.1

Summary

There shall be no data races between threads. (See page 9 of MISRA-C-2012-Amendment-4 [57] , page 45 of MISRA-C-2023 [58] , page 45 of MISRA-C-2025 [59] .)

Imprecision

False positives are reported due to the undecidability of the rule

All inclusions of threads.h are reported as possible data races

Configuration

See generic service options.

Directive MC4.D5.2

Aliases

MC3.D5.2, MC3R2.D5.2, MC3A4.D5.2

Summary

There shall be no deadlocks between threads. (See page 11 of MISRA-C-2012-Amendment-4 [57] , page 47 of MISRA-C-2023 [58] , page 47 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option calls
calls
-config=MC4.D5.2,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.D5.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Directive MC4.D5.3

Aliases

MC3.D5.3, MC3R2.D5.3, MC3A4.D5.3

Summary

There shall be no dynamic thread creation. (See page 12 of MISRA-C-2012-Amendment-4 [57] , page 48 of MISRA-C-2023 [58] , page 48 of MISRA-C-2025 [59] .)

Description

Reports functions that directly or indirectly call the Standard Library function thrd_create and have their address taken, thereby potentially causing the creation a thread outside a well-defined program start-up phase

Imprecision

False positives due to undecidability of the guideline.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.D5.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3R1.R1.1

Aliases

MC3C1.R1.1, MC3A1.R1.1, MC3R0.R1.1

Summary

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits. (See page 45 of MISRA-C-2012 [45] , page 46 of MISRA-C-2012-Revision-1 [51] .)

Description

This service reports all non-standard syntax and constraint violations including any extensions to the standard unless these are specified using the behavior service configuration of the related ancillary services.

In the absence of a specific configuration, most extensions of the applicable language standard will be reported as non-compliant by this service.

If it is decided that (some of) these actually refer to supported compiler extensions, then by using the behavior configuration of the related ancillary services, these will not be reported by this service, but will be subject to Rule 1.2.

Consider the following example:

__asm("NOP");

The token __asm, being non-standard for C99, is non-compliant for the ancillary service STD.tokenext and hence is reported as a violation by this service.

On the other hand, if we add the service configuration

-doc='__asm, __asm are documented extension, see Chapter "Extensions to the C Language Family" of the compiler manual.'
-config=STD.tokenext,behavior={c99, "^.*$", "^_*asm_*$"}

then the code is now compliant for this service but is non-compliant for Rule 1.2.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.flexaray STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.extident STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC3R1.R1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=MC3R1.R1.1,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=MC3R1.R1.1,standards=c90||c95||c99

Rule MC3C2.R1.1

Aliases

MC3A2.R1.1

Summary

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits. (See page 17 of MISRA-C-2012-Amendment-2 [52] .)

Description

This service reports all non-standard syntax and constraint violations including any extensions to the standard unless these are specified using the behavior service configuration of the related ancillary services.

In the absence of a specific configuration, most extensions of the applicable language standard will be reported as non-compliant by this service.

If it is decided that (some of) these actually refer to supported compiler extensions, then by using the behavior configuration of the related ancillary services, these will not be reported by this service, but will be subject to Rule 1.2.

Consider the following example:

__asm("NOP");

The token __asm, being non-standard for C99, is non-compliant for the ancillary service STD.tokenext and hence is reported as a violation by this service.

On the other hand, if we add the service configuration

-doc='__asm, __asm are documented extension, see Chapter "Extensions to the C Language Family" of the compiler manual.'
-config=STD.tokenext,behavior={c99, "^.*$", "^_*asm_*$"}

then the code is now compliant for this service but is non-compliant for Rule 1.2.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.flexaray STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.extident STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC3C2.R1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=MC3C2.R1.1,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=MC3C2.R1.1,standards=c90||c95||c99||c11

Rule MC4.R1.1

Aliases

MC3.R1.1, MC3R2.R1.1, MC3A4.R1.1, MC3A3.R1.1

Summary

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits. (See page 49 of MISRA-C-2023 [58] , page 49 of MISRA-C-2025 [59] .)

Description

This service reports all non-standard syntax and constraint violations including any extensions to the standard unless these are specified using the behavior service configuration of the related ancillary services.

In the absence of a specific configuration, most extensions of the applicable language standard will be reported as non-compliant by this service.

If it is decided that (some of) these actually refer to supported compiler extensions, then by using the behavior configuration of the related ancillary services, these will not be reported by this service, but will be subject to Rule 1.2.

Consider the following example:

__asm("NOP");

The token __asm, being non-standard for C99, is non-compliant for the ancillary service STD.tokenext and hence is reported as a violation by this service.

On the other hand, if we add the service configuration

-doc='__asm, __asm are documented extension, see Chapter "Extensions to the C Language Family" of the compiler manual.'
-config=STD.tokenext,behavior={c99, "^.*$", "^_*asm_*$"}

then the code is now compliant for this service but is non-compliant for Rule 1.2.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.flexaray STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.extident STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC4.R1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=MC4.R1.1,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=MC4.R1.1,standards=c90||c95||c99||c11||c18

Rule MC3.R1.2

Aliases

MC3R2.R1.2, MC3A4.R1.2, MC3A3.R1.2, MC3C2.R1.2, MC3A2.R1.2, MC3R1.R1.2, MC3C1.R1.2, MC3A1.R1.2, MC3R0.R1.2

Summary

Language extensions should not be used. (See page 46 of MISRA-C-2012 [45] , page 47 of MISRA-C-2012-Revision-1 [51] , page 50 of MISRA-C-2023 [58] .)

Description

This service reports any extension to the standard for any non-standard syntax or constraint violation that has been specified using the behavior configuration of the related ancillary services.

In the absence of a specific configuration, most extensions of the applicable language standard will be reported as violations of Rule 1.1.

If it is decided that (some of) these actually refer to supported compiler extensions, then by using the behavior configuration of the related ancillary services, these extensions will be reported by this service, but will not be reported as violations of Rule 1.1.

Consider the following example:

__asm("NOP");

The token __asm, being non-standard for C99, is non-compliant for the ancillary service STD.tokenext and hence is reported as a violation of Rule 1.1 but, as it has not been specified to be an extension, it is not reported by this service.

On the other hand, if we add the service configuration

-doc='See Chapter "Extensions to the C Language Family" of the compiler manual.'
-config=STD.tokenext,behavior={c99, "^.*$", "^_*asm_*$"}

then the code is a specified extension and hence, although it is reported as a violation by this service it is now compliant for Rule 1.1.

Imprecision

Cautions are reported when the use of an extension cannot be determined.

When the use of an extension is undecidable, the related ancillary service will report possible non-compliance as a caution.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.anonstct STD.araystat STD.arayzero STD.arthinvl STD.bincondl STD.bitfwdth STD.bsercheq STD.caseuplw STD.castunon STD.charescp STD.charset STD.charxwde STD.cmntstle STD.cmpdltrl STD.declmixd STD.decltype STD.defined STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.eofnl STD.flexaray STD.fntpqual STD.forhdecl STD.fprscarg STD.fprscfmt STD.funojptr STD.funptrcv STD.hdrexpnd STD.hostmain STD.iddiflkg STD.iddollar STD.implfunc STD.indxcnst STD.indxvltl STD.intconvn STD.intnlobj STD.ipconrep STD.linedir STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macrsynt STD.macrvarg STD.mainrtrn STD.ncstinit STD.negshift STD.nodecltr STD.nonstdc STD.ppcomma STD.prepdirc STD.pteincmp STD.ptrnconv STD.qotemtch STD.qsortord STD.redltype STD.rtrnemty STD.rvalsubs STD.stdcctxt STD.stdcprag STD.stdtypes STD.stmtexpr STD.strincmp STD.strlitrl STD.tokenext STD.vaargast STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC3.R1.2,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC3C2.R1.3

Aliases

MC3A2.R1.3, MC3R1.R1.3, MC3C1.R1.3, MC3A1.R1.3, MC3R0.R1.3

Summary

There shall be no occurrence of undefined or critical unspecified behaviour. (See page 46 of MISRA-C-2012 [45] , page 47 of MISRA-C-2012-Revision-1 [51] , page 17 of MISRA-C-2012-Amendment-2 [52] .)

Description

The behavior configuration of the related ancillary services that has an associated -doc can be used to specify the behavior and documentation. The service reports all instances of undefined behaviours that refer to this rule and are listed in this table, each with the indicated precision. No guarantees are made with respect to critical unspecified behaviours.

Imprecision

Cautions are reported when the behavior item is undecidable.

When the undefined or critical unspecified behavior item is undecidable, the related ancillary service will report possible non-compliance as a caution.

False negatives are possible for those behaviors not otherwise listed.

This service depends upon the configuration of the following ancillary services: STD.anonstct STD.charescp STD.charset STD.charxwde STD.defined STD.encderor STD.eofnl STD.fntpqual STD.hostmain STD.iddiflkg STD.intnlobj STD.linedir STD.nonstdc STD.stdcctxt STD.stdcprag

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC3C2.R1.3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC4.R1.3

Aliases

MC3.R1.3, MC3R2.R1.3, MC3A4.R1.3, MC3A3.R1.3

Summary

There shall be no occurrence of undefined or critical unspecified behaviour. (See page 46 of MISRA-C-2012 [45] , page 51 of MISRA-C-2023 [58] , page 51 of MISRA-C-2025 [59] .)

Description

The behavior configuration of the related ancillary services that has an associated -doc can be used to specify the behavior and documentation. The service reports all instances of undefined behaviours that refer to this rule and are listed in this table for MC, each with the indicated precision. No guarantees are made with respect to critical unspecified behaviours.

Imprecision

Cautions are reported when the behavior item is undecidable.

When the undefined or critical unspecified behavior item is undecidable, the related ancillary service will report possible non-compliance as a caution.

False negatives are possible for those behaviors not otherwise listed.

This service depends upon the configuration of the following ancillary services: STD.anonstct STD.charescp STD.charset STD.charxwde STD.defined STD.encderor STD.eofnl STD.hostmain STD.iddiflkg STD.intnlobj STD.linedir STD.nonstdc STD.stdcctxt STD.stdcprag

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC4.R1.3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC3C2.R1.4

Aliases

MC3A2.R1.4

Summary

Emergent language features shall not be used. (See page 18 of MISRA-C-2012-Amendment-2 [52] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

The service reports the following:

  • any use of the bounds-checking interfaces (see Annex K of the [40]), other than definining __STDC_WANT_LIB_EXT1__ to “0”

  • the _Atomic type specifier and inclusion of the header stdatomic.h or cstdatomic;

  • the _Thread_local storage class specifier and inclusion of the header threads.h or cthreads;

  • the _Generic operator;

  • the _Noreturn function specifier and inclusion of the header stdnoreturn.h or cstdnoreturn;

  • the _Alignas alignment specifier, the _Alignof operator and inclusion of the header stdalign.h or cstdalign.

Configuration

See generic service options.

Option macros
macros
-config=MC3C2.R1.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option reserved_standard
reserved_standard
-config=MC3C2.R1.4,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC3C2.R1.4,reserved_standard="max(c11)", c++11

Option declarations
declarations
-config=MC3C2.R1.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3A3.R1.4

Aliases

Summary

Emergent language features shall not be used. (See page 15 of MISRA-C-2012-Amendment-3 [55] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

The service reports the following:

  • any use of the bounds-checking interfaces (see Annex K of the [40]), other than definining __STDC_WANT_LIB_EXT1__ to “0”

  • the _Atomic type specifier and inclusion of the header stdatomic.h or cstdatomic;

  • the _Thread_local storage class specifier and inclusion of the header threads.h or cthreads.

Configuration

See generic service options.

Option macros
macros
-config=MC3A3.R1.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option reserved_standard
reserved_standard
-config=MC3A3.R1.4,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC3A3.R1.4,reserved_standard="max(c11)", c++11

Option declarations
declarations
-config=MC3A3.R1.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R1.4

Aliases

MC3.R1.4, MC3R2.R1.4, MC3A4.R1.4

Summary

Emergent language features shall not be used. (See page 15 of MISRA-C-2012-Amendment-4 [57] , page 52 of MISRA-C-2023 [58] , page 52 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

The service reports the following:

  • any use of the bounds-checking interfaces (see Annex K of the [40]), other than definining __STDC_WANT_LIB_EXT1__ to “0”.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R1.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option reserved_standard
reserved_standard
-config=MC4.R1.4,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC4.R1.4,reserved_standard="max(c11)", c++11

Option declarations
declarations
-config=MC4.R1.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R1.5

Aliases

MC3.R1.5, MC3R2.R1.5, MC3A4.R1.5, MC3A3.R1.5

Summary

Obsolescent language features shall not be used. (See page 15 of MISRA-C-2012-Amendment-3 [55] , page 52 of MISRA-C-2023 [58] , page 52 of MISRA-C-2025 [59] .)

Description

Obsolescent features are listed in page 293 of MISRA C:2023 [58]

Imprecision

Cautions are reported on any usage of the ungetc standard library function and the realloc standard library function, when the second argument may be 0

Configuration

See generic service options.

Option macros
macros
-config=MC4.R1.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC4.R1.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option calls
calls
-config=MC4.R1.5,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R1.5,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option types
types
-config=MC4.R1.5,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option reserved_standard
reserved_standard
-config=MC4.R1.5,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC4.R1.5,reserved_standard="min(c99)"

Rule MC3C2.R2.1

Aliases

MC3A2.R2.1, MC3R1.R2.1, MC3C1.R2.1, MC3A1.R2.1, MC3R0.R2.1

Summary

A project shall not contain unreachable code. (See page 47 of MISRA-C-2012 [45] , page 10 of MISRA-C-2012-Permits-1 [53] , page 11 of MISRA-C-2012-Permits-1 [53] .)

Description

The rule reports:

  • defined functions that are never referenced;

  • unreachable code;

  • constant unfeasible code;

  • any unit compiled but not linked.

Notes:

  • A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

  • If the context of a deliberately unreachable statement or expression is a selection or iteration statement and the unreachability is due to its condition or guard, then the report can be tagged using the statements service configuration where the matcher targets the context (see below for an example).

  • Unused declarations can be tagged using the declarations service configuration; in particular, declarations in public API files may be hidden by:

    • using the tag hide;

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

Examples:

With the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library entry points not necessarily have to be referenced."
-config=MC3C2.R2.1,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

With the configuration lines:

-doc="constexpr if statements are expected to have unreachable branches."
-config=MC3C2.R2.1,+statements={known,"node(if_stmt)&&kind(constexpr))"}

reports for unreachable nodes in the false branch of a constexpr if statement will be tagged known.

Imprecision

False negatives can occur when the analyzer cannot guarantee the code will never reach a conditional branch or exit a loop.

Configuration

See generic service options.

Option declarations
declarations
-config=MC3C2.R2.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_stmts
ignored_stmts
-config=MC3C2.R2.1,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option statements
statements
-config=MC3C2.R2.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option all_decls
all_decls
-config=MC3C2.R2.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option diagnostics
diagnostics
-config=MC3C2.R2.1,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MC4.R2.1

Aliases

MC3.R2.1, MC3R2.R2.1, MC3A4.R2.1, MC3A3.R2.1

Summary

A project shall not contain unreachable code. (See page 48 of MISRA-C-2012-Revision-1 [51] , page 53 of MISRA-C-2023 [58] , page 53 of MISRA-C-2025 [59] , page 10 of MISRA-C-2012-Permits-1 [53] , page 11 of MISRA-C-2012-Permits-1 [53] .)

Description

The rule reports:

  • defined functions that are never referenced;

  • unreachable code;

  • constant unfeasible code;

  • any unit compiled but not linked.

Notes:

  • A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

  • If the context of a deliberately unreachable statement or expression is a selection or iteration statement and the unreachability is due to its condition or guard, then the report can be tagged using the statements service configuration where the matcher targets the context (see below for an example).

  • Unused declarations can be tagged using the declarations service configuration; in particular, declarations in public API files may be hidden by:

    • using the tag hide;

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

Examples:

With the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library entry points not necessarily have to be referenced."
-config=MC4.R2.1,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

With the configuration lines:

-doc="constexpr if statements are expected to have unreachable branches."
-config=MC4.R2.1,+statements={known,"node(if_stmt)&&kind(constexpr))"}

reports for unreachable nodes in the false branch of a constexpr if statement will be tagged known.

Imprecision

False negatives can occur when the analyzer cannot guarantee the code will never reach a conditional branch or exit a loop.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R2.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_stmts
ignored_stmts
-config=MC4.R2.1,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option statements
statements
-config=MC4.R2.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option all_decls
all_decls
-config=MC4.R2.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option diagnostics
diagnostics
-config=MC4.R2.1,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MC3A3.R2.2

Aliases

MC3C2.R2.2, MC3A2.R2.2, MC3R1.R2.2, MC3C1.R2.2, MC3A1.R2.2, MC3R0.R2.2

Summary

There shall be no dead code. (See page 49 of MISRA-C-2012 [45] , page 8 of MISRA-C-2012-TC1 [48] , page 50 of MISRA-C-2012-Revision-1 [51] , page 9 of MISRA-C-2012-TC2 [54] .)

Description

Any expression whose value is ignored and has no side effects is reported.

Notes:

  • an action is considered to be a side effect only when it is caused by the external operator/functor of the expression (and is not just an effect of its sub-expressions);

  • an explicit cast to void is not reported.

  • initialization is not reported.

Imprecision

Cautions are reported when the checker is uncertain if the code is dead code.

It is not always possible to distinguish possibly dead code from any other code.

False negatives are present when there is a call to a void function that has no effect (external or any changes to the function’s arguments).

Configuration

See generic service options.

Rule MC4.R2.2

Aliases

MC3.R2.2, MC3R2.R2.2, MC3A4.R2.2

Summary

A project shall not contain dead code. (See page 55 of MISRA-C-2023 [58] , page 55 of MISRA-C-2025 [59] .)

Description

Any expression whose value is ignored and has no side effects is reported.

Notes:

  • an action is considered to be a side effect only when it is caused by the external operator/functor of the expression (and is not just an effect of its sub-expressions);

  • an explicit cast to void is not reported.

  • initialization is not reported.

Imprecision

Cautions are reported when the checker is uncertain if the code is dead code.

It is not always possible to distinguish possibly dead code from any other code.

False negatives are present when there is a call to a void function that has no effect (external or any changes to the function’s arguments).

Configuration

See generic service options.

Rule MC4.R2.3

Aliases

MC3.R2.3, MC3R2.R2.3, MC3A4.R2.3, MC3A3.R2.3, MC3C2.R2.3, MC3A2.R2.3, MC3R1.R2.3, MC3C1.R2.3, MC3A1.R2.3, MC3R0.R2.3

Summary

A project should not contain unused type declarations. (See page 51 of MISRA-C-2012 [45] , page 52 of MISRA-C-2012-Revision-1 [51] , page 56 of MISRA-C-2023 [58] , page 56 of MISRA-C-2025 [59] .)

Description

Note that reports about unused type declarations can be hidden using the declarations service configuration; for instance, any unused declarations in public API files can be assigned a report tag such as hide by:

  • exploiting the globally defined decl_selector __public_api_decls;

  • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Declarations in public files define a public API and do not necessarily have to be referenced."
-config=MC4.R2.3,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R2.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MC4.R2.3,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MC4.R2.4

Aliases

MC3.R2.4, MC3R2.R2.4, MC3A4.R2.4, MC3A3.R2.4, MC3C2.R2.4, MC3A2.R2.4, MC3R1.R2.4, MC3C1.R2.4, MC3A1.R2.4, MC3R0.R2.4

Summary

A project should not contain unused tag declarations. (See page 51 of MISRA-C-2012 [45] , page 52 of MISRA-C-2012-Revision-1 [51] , page 56 of MISRA-C-2023 [58] , page 56 of MISRA-C-2025 [59] .)

Description

Note that reports about unused tag declarations can be hidden using the declarations service configuration; for instance, any unused declarations in public API files can be assigned a report tag such as hide by:

  • exploiting the globally defined decl_selector __public_api_decls;

  • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Tag declarations in public files define a public API and do not necessarily have to be referenced."
-config=MC4.R2.4,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R2.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MC4.R2.4,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MC3A2.R2.5

Aliases

MC3R1.R2.5, MC3C1.R2.5, MC3A1.R2.5, MC3R0.R2.5

Summary

A project should not contain unused macro declarations. (See page 52 of MISRA-C-2012 [45] , page 53 of MISRA-C-2012-Revision-1 [51] .)

Description

Notes:

  • Use of the directive #undef of a macro is considered to be a use of the macro.

  • Reports about unused macro definitions can be hidden using the macros service configuration; for instance, any unused definitions in public API files can be assigned a report tag such as hide by:

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Macro definitions in public files define a public API and do not necessarily have to be referenced."
-config=MC3A2.R2.5,+macro={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Configuration

See generic service options.

Option macros
macros
-config=MC3A2.R2.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R2.5

Aliases

MC3.R2.5, MC3R2.R2.5, MC3A4.R2.5, MC3A3.R2.5, MC3C2.R2.5

Summary

A project should not contain unused macro definitions. (See page 9 of MISRA-C-2012-TC2 [54] , page 57 of MISRA-C-2023 [58] , page 57 of MISRA-C-2025 [59] .)

Description

Notes:

  • Use of the directive #undef of a macro is considered to be a use of the macro.

  • Reports about unused macro definitions can be hidden using the macros service configuration; for instance, any unused definitions in public API files can be assigned a report tag such as hide by:

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Macro definitions in public files define a public API and do not necessarily have to be referenced."
-config=MC4.R2.5,+macro={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R2.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R2.6

Aliases

MC3.R2.6, MC3R2.R2.6, MC3A4.R2.6, MC3A3.R2.6, MC3C2.R2.6, MC3A2.R2.6, MC3R1.R2.6, MC3C1.R2.6, MC3A1.R2.6, MC3R0.R2.6

Summary

A function should not contain unused label declarations. (See page 52 of MISRA-C-2012 [45] , page 53 of MISRA-C-2012-Revision-1 [51] , page 9 of MISRA-C-2012-TC2 [54] , page 58 of MISRA-C-2023 [58] , page 58 of MISRA-C-2025 [59] .)

Description

Any label in a labeled statement is used if:

  • it is the label in a direct goto statement, or

  • its address is taken and there is an indirect goto statement.

Configuration

See generic service options.

Option statements
statements
-config=MC4.R2.6,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC3A3.R2.7

Aliases

MC3C2.R2.7, MC3A2.R2.7, MC3R1.R2.7, MC3C1.R2.7, MC3A1.R2.7, MC3R0.R2.7

Summary

There should be no unused parameters in functions. (See page 52 of MISRA-C-2012 [45] , page 54 of MISRA-C-2012-Revision-1 [51] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC3A3.R2.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R2.7

Aliases

MC3.R2.7, MC3R2.R2.7, MC3A4.R2.7

Summary

A function should not contain unused parameters. (See page 58 of MISRA-C-2023 [58] , page 58 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R2.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R2.8

Aliases

MC3.R2.8, MC3R2.R2.8, MC3A4.R2.8

Summary

A project should not contain unused object definitions. (See page 14 of MISRA-C-2012-Amendment-4 [57] , page 58 of MISRA-C-2023 [58] , page 58 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R2.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MC4.R2.8,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MC3A3.R3.1

Aliases

MC3C2.R3.1, MC3A2.R3.1, MC3R1.R3.1, MC3C1.R3.1, MC3A1.R3.1, MC3R0.R3.1

Summary

The character sequences /* and // shall not be used within a comment. (See page 53 of MISRA-C-2012 [45] , page 54 of MISRA-C-2012-Revision-1 [51] .)

Configuration

See generic service options.

Option comments
comments
-config=MC3A3.R3.1,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=MC3A3.R3.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R3.1

Aliases

MC3.R3.1, MC3R2.R3.1, MC3A4.R3.1

Summary

The character sequences /* and // shall not be used within a comment. (See page 38 of MISRA-C-2012-Amendment-4 [57] , page 59 of MISRA-C-2023 [58] , page 59 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option comments
comments
-config=MC4.R3.1,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R3.2

Aliases

MC3.R3.2, MC3R2.R3.2, MC3A4.R3.2, MC3A3.R3.2, MC3C2.R3.2, MC3A2.R3.2, MC3R1.R3.2, MC3C1.R3.2, MC3A1.R3.2, MC3R0.R3.2

Summary

Line-splicing shall not be used in // comments. (See page 54 of MISRA-C-2012 [45] , page 55 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 60 of MISRA-C-2023 [58] , page 60 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option comments
comments
-config=MC4.R3.2,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R4.1

Aliases

MC3.R4.1, MC3R2.R4.1, MC3A4.R4.1, MC3A3.R4.1, MC3C2.R4.1, MC3A2.R4.1, MC3R1.R4.1, MC3C1.R4.1, MC3A1.R4.1, MC3R0.R4.1

Summary

Octal and hexadecimal escape sequences shall be terminated. (See page 54 of MISRA-C-2012 [45] , page 56 of MISRA-C-2012-Revision-1 [51] , page 61 of MISRA-C-2023 [58] , page 61 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option literals
literals
-config=MC4.R4.1,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MC4.R4.2

Aliases

MC3.R4.2, MC3R2.R4.2, MC3A4.R4.2, MC3A3.R4.2, MC3C2.R4.2, MC3A2.R4.2, MC3R1.R4.2, MC3C1.R4.2, MC3A1.R4.2, MC3R0.R4.2

Summary

Trigraphs should not be used. (See page 55 of MISRA-C-2012 [45] , page 56 of MISRA-C-2012-Revision-1 [51] , page 61 of MISRA-C-2023 [58] , page 61 of MISRA-C-2025 [59] .)

Description

Note that trigraphs are denoted by one of the sequences ??=, ??(, ??<, ??/, ??), ??>, ??', ??|, and ??-.

Configuration

See generic service options.

Rule MC4.R5.1

Aliases

MC3.R5.1, MC3R2.R5.1, MC3A4.R5.1, MC3A3.R5.1, MC3C2.R5.1, MC3A2.R5.1, MC3R1.R5.1, MC3C1.R5.1, MC3A1.R5.1, MC3R0.R5.1

Summary

External identifiers shall be distinct. (See page 56 of MISRA-C-2012 [45] , page 57 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 62 of MISRA-C-2023 [58] , page 62 of MISRA-C-2025 [59] .)

Description

Notes:

  • The number N of significant initial characters and their case sensitivity supported by the implementation can be changed with the STD.extidsig behavior service configuration.

This service depends upon the configuration of the following ancillary services: STD.extidsig

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC4.R5.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC4.R5.1,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R5.2

Aliases

MC3.R5.2, MC3R2.R5.2, MC3A4.R5.2, MC3A3.R5.2, MC3C2.R5.2, MC3A2.R5.2, MC3R1.R5.2, MC3C1.R5.2, MC3A1.R5.2, MC3R0.R5.2

Summary

Identifiers declared in the same scope and name space shall be distinct. (See page 57 of MISRA-C-2012 [45] , page 58 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 63 of MISRA-C-2023 [58] , page 63 of MISRA-C-2025 [59] .)

Description

Notes:

  • the rule does not apply when both identifiers are external;

  • The number of significant initial characters supported by the implementation in identifiers can be changed with the STD.nexidsig behavior service configuration.

This service depends upon the configuration of the following ancillary services: STD.nexidsig

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC4.R5.2,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC4.R5.2,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R5.3

Aliases

MC3.R5.3, MC3R2.R5.3, MC3A4.R5.3, MC3A3.R5.3, MC3C2.R5.3, MC3A2.R5.3, MC3R1.R5.3, MC3C1.R5.3, MC3A1.R5.3, MC3R0.R5.3

Summary

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope. (See page 58 of MISRA-C-2012 [45] , page 59 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 64 of MISRA-C-2023 [58] , page 64 of MISRA-C-2025 [59] , page 12 of MISRA-C-2012-Permits-1 [53] .)

Description

The relation outer and inner scope, defined in MISRA C:2023 [58] , is summarized as:

  • file scope is the outermost scope;

  • each compound statement introduces a new inner scope.

Notes:

  • The number of significant initial characters supported by the implementation in identifiers can be changed with the STD.nexidsig behavior service configuration.

This service depends upon the configuration of the following ancillary services: STD.nexidsig

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC4.R5.3,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC4.R5.3,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R5.4

Aliases

MC3.R5.4, MC3R2.R5.4, MC3A4.R5.4, MC3A3.R5.4, MC3C2.R5.4, MC3A2.R5.4, MC3R1.R5.4, MC3C1.R5.4, MC3A1.R5.4, MC3R0.R5.4

Summary

Macro identifiers shall be distinct. (See page 59 of MISRA-C-2012 [45] , page 60 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 66 of MISRA-C-2023 [58] , page 66 of MISRA-C-2025 [59] .)

Description

Notes:

  • the names of a macro’s parameters must be distinct but these names do not have to be distinct between two different macros;

  • The number of significant initial characters supported by the implementation in macro and macro parameter names can be changed with the option STD.nexidsig behavior.

This service depends upon the configuration of the following ancillary services: STD.nexidsig

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC4.R5.4,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC4.R5.4,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R5.5

Aliases

MC3.R5.5, MC3R2.R5.5, MC3A4.R5.5, MC3A3.R5.5, MC3C2.R5.5, MC3A2.R5.5, MC3R1.R5.5, MC3C1.R5.5, MC3A1.R5.5, MC3R0.R5.5

Summary

Identifiers shall be distinct from macro names. (See page 61 of MISRA-C-2012 [45] , page 62 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 67 of MISRA-C-2023 [58] , page 67 of MISRA-C-2025 [59] .)

Description

Notes:

  • The number of significant initial characters supported by the implementation in identifiers and macro names can be changed with the STD.nexidsig behavior service configuration.

This service depends upon the configuration of the following ancillary services: STD.nexidsig

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC4.R5.5,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC4.R5.5,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R5.6

Aliases

MC3.R5.6, MC3R2.R5.6, MC3A4.R5.6, MC3A3.R5.6, MC3C2.R5.6, MC3A2.R5.6, MC3R1.R5.6, MC3C1.R5.6, MC3A1.R5.6, MC3R0.R5.6

Summary

A typedef name shall be a unique identifier. (See page 62 of MISRA-C-2012 [45] , page 63 of MISRA-C-2012-Revision-1 [51] , page 68 of MISRA-C-2023 [58] , page 68 of MISRA-C-2025 [59] .)

Description

This rule does not report when:

  • both entities are typedefs with the same declaration in a header file that is included in multiple source files;

  • the other entity is a struct, union or enum tag associated with the same typedef;

  • the reuse_by_location service configuration specifies allowed exceptions for pairs of identifiers that have the same fully qualified name, have internal linkage and are declared at the same location.

Qualified names are checked.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MC4.R5.6,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC4.R5.6,reuse_by_location=address

Rule MC4.R5.7

Aliases

MC3.R5.7, MC3R2.R5.7, MC3A4.R5.7, MC3A3.R5.7, MC3C2.R5.7, MC3A2.R5.7, MC3R1.R5.7, MC3C1.R5.7, MC3A1.R5.7, MC3R0.R5.7

Summary

A tag name shall be a unique identifier. (See page 63 of MISRA-C-2012 [45] , page 64 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 69 of MISRA-C-2023 [58] , page 69 of MISRA-C-2025 [59] .)

Description

The rule does not report when:

  • both entities are tag names with the same declaration in a header file that is included in multiple source files;

  • the other entity is a typedef tag associated with the same struct, union or enum;

  • the reuse_by_location service configuration specifies allowed exceptions for pairs of identifiers that have the same fully qualified name, have internal linkage and are declared at the same location.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MC4.R5.7,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC4.R5.7,reuse_by_location=address

Rule MC4.R5.8

Aliases

MC3.R5.8, MC3R2.R5.8, MC3A4.R5.8, MC3A3.R5.8, MC3C2.R5.8, MC3A2.R5.8, MC3R1.R5.8, MC3C1.R5.8, MC3A1.R5.8, MC3R0.R5.8

Summary

Identifiers that define objects or functions with external linkage shall be unique. (See page 64 of MISRA-C-2012 [45] , page 65 of MISRA-C-2012-Revision-1 [51] , page 70 of MISRA-C-2023 [58] , page 70 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R5.9

Aliases

MC3.R5.9, MC3R2.R5.9, MC3A4.R5.9, MC3A3.R5.9, MC3C2.R5.9, MC3A2.R5.9, MC3R1.R5.9, MC3C1.R5.9, MC3A1.R5.9, MC3R0.R5.9

Summary

Identifiers that define objects or functions with internal linkage should be unique. (See page 65 of MISRA-C-2012 [45] , page 66 of MISRA-C-2012-Revision-1 [51] , page 8 of MISRA-C-2012-TC1 [48] , page 71 of MISRA-C-2023 [58] , page 71 of MISRA-C-2025 [59] .)

Description

A variable or function with static storage duration is reported if its identifier is reused by any other entity in the program.

Note that:

  • a function or variable with internal linkage may be defined in more than one translation unit provided all such definitions are made in the same header file that is included in each unit;

  • the summarize_max service configuration provides an alternative so that, instead of marking all instances of an identifier’s reuse, the rule reports a specified number of such instances as well as the total number of times the name of the identifier is used.

Configuration

See generic service options.

Option summarize_max
summarize_max
-config=MC4.R5.9,summarize_max=MAX

Specify the maximum number of clashes to be shown.

MAX:

if Max = -1 or the number of clashes for an identifier is less than or equal to Max, then all the clashes are shown. Otherwise only Max clashes are shown and a program summary will show the total number of clashes for that identifier. It must be an integer greater than or equal to -1.

Default:

-config=MC4.R5.9,summarize_max=0

Option reuse_by_location
reuse_by_location
-config=MC4.R5.9,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC4.R5.9,reuse_by_location=address

Rule MC4.R5.10

Aliases

Summary

A reserved identifier or reserved macro name shall not be declared. (See page 204 of MISRA-C-2025 [59] .)

Description

The reserved identifiers are defined to be any names that begin with an underscore or identifiers in file scope that are reserved by the standard used by the translation unit.

The reserved macros are defined to be any names that begin with an underscore or macros that are reserved by the standard used by the translation unit.

If the compiler language is C++, then namespace and tag qualifiers are considered relevant.

Note that this rule is only for non-preprocessor identifiers such as objects, function names and typedefs.

The default configuration checks identifiers that are reserved by the standard library; to specify that identifiers provided by the project standard library posix are also reserved, use the -stdlib global configuration with the reserved_standard service configuration. For example, with the configuration lines:

-+stdlib=posix
-config=MC4.R5.10,reserved_standard+="posix"

the reserved identifiers in the posix library will be checked.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+={my_lib, c, 2022, c, "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)", "file_scope"}

Then with the service configuration line

-config=MC4.R5.10,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC4.R5.10,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC4.R5.10,reserved_standard="std()"

Option declarations
declarations
-config=MC4.R5.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R6.1

Aliases

MC3.R6.1, MC3R2.R6.1, MC3A4.R6.1, MC3A3.R6.1, MC3C2.R6.1, MC3A2.R6.1, MC3R1.R6.1, MC3C1.R6.1, MC3A1.R6.1, MC3R0.R6.1

Summary

Bit-fields shall only be declared with an appropriate type. (See page 66 of MISRA-C-2012 [45] , page 67 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 73 of MISRA-C-2023 [58] , page 73 of MISRA-C-2025 [59] , page 13 of MISRA-C-2012-Permits-1 [53] .)

Description

The defined type for bitfields must be:

  • for the C90 standard [34]: either signed int or unsigned int;

  • for the C99 standard [37]: one of signed int, unsigned int, _Bool, or other explicitly signed or unsigned types that have been enabled by the STD.bitfldtp behavior service configuration.

Note that, for this service, the report category is the reported type.

This service depends upon the configuration of the following ancillary services: STD.bitfldtp STD.bitfsign

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC4.R6.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC4.R6.2

Aliases

MC3.R6.2, MC3R2.R6.2, MC3A4.R6.2, MC3A3.R6.2, MC3C2.R6.2, MC3A2.R6.2, MC3R1.R6.2, MC3C1.R6.2, MC3A1.R6.2, MC3R0.R6.2

Summary

Single-bit named bit fields shall not be of a signed type. (See page 67 of MISRA-C-2012 [45] , page 68 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-Amendment-2 [52] , page 74 of MISRA-C-2023 [58] , page 74 of MISRA-C-2025 [59] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R6.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC4.R6.2,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC4.R6.3

Aliases

MC3.R6.3, MC3R2.R6.3, MC3A4.R6.3, MC3A3.R6.3

Summary

A bit field shall not be declared as a member of a union. (See page 16 of MISRA-C-2012-Amendment-3 [55] , page 74 of MISRA-C-2023 [58] , page 74 of MISRA-C-2025 [59] .)

Description

The rule does not apply to fields of struct objects, even when they are themselves fields of a union.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R6.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R7.1

Aliases

MC3.R7.1, MC3R2.R7.1, MC3A4.R7.1, MC3A3.R7.1, MC3C2.R7.1, MC3A2.R7.1, MC3R1.R7.1, MC3C1.R7.1, MC3A1.R7.1, MC3R0.R7.1

Summary

Octal constants shall not be used. (See page 67 of MISRA-C-2012 [45] , page 68 of MISRA-C-2012-Revision-1 [51] , page 75 of MISRA-C-2023 [58] , page 75 of MISRA-C-2025 [59] , page 14 of MISRA-C-2012-Permits-1 [53] .)

Exceptions

The integer constant 0 and the octal escape sequences are allowed.

Configuration

See generic service options.

Option literals
literals
-config=MC4.R7.1,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MC4.R7.2

Aliases

MC3.R7.2, MC3R2.R7.2, MC3A4.R7.2, MC3A3.R7.2, MC3C2.R7.2, MC3A2.R7.2, MC3R1.R7.2, MC3C1.R7.2, MC3A1.R7.2, MC3R0.R7.2

Summary

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type. (See page 68 of MISRA-C-2012 [45] , page 69 of MISRA-C-2012-Revision-1 [51] , page 20 of MISRA-C-2012-Amendment-2 [52] , page 76 of MISRA-C-2023 [58] , page 76 of MISRA-C-2025 [59] , page 14 of MISRA-C-2012-Permits-1 [53] .)

Description

Notes:

  • the context in which the constant is used is not relevant;

  • the inferred type for the integer constants is based on the table on page 56 of the C99 standard [37].

Configuration

See generic service options.

Option literals
literals
-config=MC4.R7.2,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MC4.R7.3

Aliases

MC3.R7.3, MC3R2.R7.3, MC3A4.R7.3, MC3A3.R7.3, MC3C2.R7.3, MC3A2.R7.3, MC3R1.R7.3, MC3C1.R7.3, MC3A1.R7.3, MC3R0.R7.3

Summary

The lowercase character l shall not be used in a literal suffix. (See page 69 of MISRA-C-2012 [45] , page 70 of MISRA-C-2012-Revision-1 [51] , page 77 of MISRA-C-2023 [58] , page 77 of MISRA-C-2025 [59] , page 15 of MISRA-C-2012-Permits-1 [53] .)

Configuration

See generic service options.

Option literals
literals
-config=MC4.R7.3,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MC4.R7.4

Aliases

MC3.R7.4, MC3R2.R7.4, MC3A4.R7.4, MC3A3.R7.4, MC3C2.R7.4, MC3A2.R7.4, MC3R1.R7.4, MC3C1.R7.4, MC3A1.R7.4, MC3R0.R7.4

Summary

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char“. (See page 70 of MISRA-C-2012 [45] , page 71 of MISRA-C-2012-Revision-1 [51] , page 20 of MISRA-C-2012-Amendment-2 [52] , page 10 of MISRA-C-2012-TC2 [54] , page 78 of MISRA-C-2023 [58] , page 78 of MISRA-C-2025 [59] .)

Description

Similarly a wide string literal must not be assigned to an object whose type is not a const-qualified wchar_t.

Notes:

  • if the type of the string literal or wide string literal is const char[] or const wchar_t[], then no checks are made since any removal of the qualifier will be reported as a violation of Service MC.R11.8;

  • there is no violation if the string literal is assigned to an array of char or wchar_t;

  • the same_pointee service configuration may be used to specify if the string literal and the pointer referring to the string literal must point to the same character type.

  • a caution is reported if a string literal is passed to a function and it is unknown how the function may use the literal;

Note that the -call_properties global configuration can be used to specify the call property pointee_write for arguments. For example, with the code:

void f(int, ...);
void g(void) { f(0, "a"); }

The service will, by default, report a caution. However, with the following configuration line, ECLAIR will assume that the none of the variadic arguments (with index 2 or more) for f will be written and there will be no report:

-call_properties+={decl(name(f))",{"pointee_write(2..=never)"}}

Imprecision

Cautions are reported when the string literal is passed to a function and it is unknown how the function may use the literal.

Configuration

See generic service options.

Option same_pointee
same_pointee
-config=MC4.R7.4,same_pointee=BOOL

Specify if the string literal and the pointer referring to the string literal must point to the same character type.

BOOL:

boolean. Accepted values are:

  • true: the string literal and the pointer referring to the string literal must point to the same character type;

  • false: the string literal and the pointer referring to the string literal do not have to point to the same type;

Default:

-config=MC4.R7.4,same_pointee=true

Rule MC4.R7.5

Aliases

MC3.R7.5, MC3R2.R7.5, MC3A4.R7.5, MC3A3.R7.5

Summary

The argument of an integer constant macro shall have an appropriate form. (See page 17 of MISRA-C-2012-Amendment-3 [55] , page 80 of MISRA-C-2023 [58] , page 80 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R7.6

Aliases

MC3.R7.6, MC3R2.R7.6, MC3A4.R7.6

Summary

The small integer variants of the minimum-width integer constant macros shall not be used. (See page 14 of MISRA-C-2012-Amendment-4 [57] , page 81 of MISRA-C-2023 [58] , page 81 of MISRA-C-2025 [59] .)

Description

Minimum-width integer constant macros are shown

Configuration

See generic service options.

Rule MC4.R8.1

Aliases

MC3.R8.1, MC3R2.R8.1, MC3A4.R8.1, MC3A3.R8.1, MC3C2.R8.1, MC3A2.R8.1, MC3R1.R8.1, MC3C1.R8.1, MC3A1.R8.1, MC3R0.R8.1

Summary

Types shall be explicitly specified. (See page 71 of MISRA-C-2012 [45] , page 72 of MISRA-C-2012-Revision-1 [51] , page 82 of MISRA-C-2023 [58] , page 82 of MISRA-C-2025 [59] .)

Description

More specifically:

  • the type of any parameter or variable must be explicitly stated;

  • the type of any member must be explicitly stated;

  • the type of the return value of any function must be explicitly stated.

  • the type of any typedef declaration must be explicitly stated.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.2

Aliases

MC3.R8.2, MC3R2.R8.2, MC3A4.R8.2, MC3A3.R8.2, MC3C2.R8.2, MC3A2.R8.2, MC3R1.R8.2, MC3C1.R8.2, MC3A1.R8.2, MC3R0.R8.2

Summary

Function types shall be in prototype form with named parameters. (See page 72 of MISRA-C-2012 [45] , page 73 of MISRA-C-2012-Revision-1 [51] , page 11 of MISRA-C-2012-TC2 [54] , page 83 of MISRA-C-2023 [58] , page 83 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC4.R8.2,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC4.R8.3

Aliases

MC3.R8.3, MC3R2.R8.3, MC3A4.R8.3, MC3A3.R8.3, MC3C2.R8.3, MC3A2.R8.3, MC3R1.R8.3, MC3C1.R8.3, MC3A1.R8.3, MC3R0.R8.3

Summary

All declarations of an object or function shall use the same names and type qualifiers. (See page 74 of MISRA-C-2012 [45] , page 75 of MISRA-C-2012-Revision-1 [51] , page 11 of MISRA-C-2012-TC2 [54] , page 84 of MISRA-C-2023 [58] , page 84 of MISRA-C-2025 [59] .)

Description

Declarations and definitions of the same variable or function are reported unless:

  1. they are for a variable with compatible types and type qualifiers,

  2. they are function prototype declarations or definitions and

    • if their corresponding parameters are named the, then the names must be the same;

    • their corresponding parameters must have compatible base types or have the same typedef names with the same type qualifiers;

    • and their return types must have compatible base types or have the same typedef names with the same type qualifiers.

Note that function definitions without a prototype declaration are not checked.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.4

Aliases

MC3.R8.4, MC3R2.R8.4, MC3A4.R8.4, MC3A3.R8.4, MC3C2.R8.4, MC3A2.R8.4, MC3R1.R8.4, MC3C1.R8.4, MC3A1.R8.4, MC3R0.R8.4

Summary

A compatible declaration shall be visible when an object or function with external linkage is defined. (See page 75 of MISRA-C-2012 [45] , page 76 of MISRA-C-2012-Revision-1 [51] , page 8 of MISRA-C-2012-TC1 [48] , page 86 of MISRA-C-2023 [58] , page 86 of MISRA-C-2025 [59] , page 15 of MISRA-C-2012-Permits-1 [53] .)

Description

Note that the rule applies to every object or function with external linkage except for the function main.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.5

Aliases

MC3.R8.5, MC3R2.R8.5, MC3A4.R8.5, MC3A3.R8.5, MC3C2.R8.5, MC3A2.R8.5, MC3R1.R8.5, MC3C1.R8.5, MC3A1.R8.5, MC3R0.R8.5

Summary

An external object or function shall be declared once in one and only one file. (See page 77 of MISRA-C-2012 [45] , page 78 of MISRA-C-2012-Revision-1 [51] , page 87 of MISRA-C-2023 [58] , page 87 of MISRA-C-2025 [59] , page 15 of MISRA-C-2012-Permits-1 [53] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.6

Aliases

MC3.R8.6, MC3R2.R8.6, MC3A4.R8.6, MC3A3.R8.6, MC3C2.R8.6, MC3A2.R8.6, MC3R1.R8.6, MC3C1.R8.6, MC3A1.R8.6, MC3R0.R8.6

Summary

An identifier with external linkage shall have exactly one external definition. (See page 77 of MISRA-C-2012 [45] , page 78 of MISRA-C-2012-Revision-1 [51] , page 88 of MISRA-C-2023 [58] , page 88 of MISRA-C-2025 [59] .)

Description

A project can specify external definitions using the -extra_definitions global configuration.

This is particularly useful when entities defined by linker, assembler, or external libraries are used.

Example of use:

-doc="entity_name is defined in ... "
-extra_definitions+="name(entity_name)"

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.7

Aliases

MC3.R8.7, MC3R2.R8.7, MC3A4.R8.7, MC3A3.R8.7, MC3C2.R8.7, MC3A2.R8.7, MC3R1.R8.7, MC3C1.R8.7, MC3A1.R8.7, MC3R0.R8.7

Summary

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit. (See page 78 of MISRA-C-2012 [45] , page 79 of MISRA-C-2012-Revision-1 [51] , page 12 of MISRA-C-2012-TC2 [54] , page 89 of MISRA-C-2023 [58] , page 89 of MISRA-C-2025 [59] .)

Description

A variable or function is reported if:

  • it has external linkage; and

  • either there are no references or all references to it are in the same unit.

Configuration

See generic service options.

Option definition_in_same_unit
definition_in_same_unit
-config=MC4.R8.7,definition_in_same_unit=BOOL

Specify if the definition must be in the same translation unit as the references.

BOOL

Accepted values are:

  • true: the definition must be in the same translation unit as the references;

  • false: the definition does not have to be in the same translation unit as the references;

Default:

-config=MC4.R8.7,definition_in_same_unit=true

Option declarations
declarations
-config=MC4.R8.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.8

Aliases

MC3.R8.8, MC3R2.R8.8, MC3A4.R8.8, MC3A3.R8.8, MC3C2.R8.8, MC3A2.R8.8, MC3R1.R8.8, MC3C1.R8.8, MC3A1.R8.8, MC3R0.R8.8

Summary

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage. (See page 78 of MISRA-C-2012 [45] , page 79 of MISRA-C-2012-Revision-1 [51] , page 90 of MISRA-C-2023 [58] , page 90 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3A3.R8.9

Aliases

MC3C2.R8.9, MC3A2.R8.9, MC3R1.R8.9, MC3C1.R8.9, MC3A1.R8.9, MC3R0.R8.9

Summary

An object should be defined at block scope if its identifier only appears in a single function. (See page 79 of MISRA-C-2012 [45] , page 80 of MISRA-C-2012-Revision-1 [51] .)

Description

A variable is reported if:

  • it has linkage;

  • it is referenced;

  • all references to it are in the same function; and

  • if it has external linkage, then all references are in the same unit.

Configuration

See generic service options.

Option declarations
declarations
-config=MC3A3.R8.9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.9

Aliases

MC3.R8.9, MC3R2.R8.9, MC3A4.R8.9

Summary

An object should be declared at block scope if its identifier only appears in a single function. (See page 39 of MISRA-C-2012-Amendment-4 [57] , page 90 of MISRA-C-2023 [58] , page 90 of MISRA-C-2025 [59] .)

Description

A variable is reported if:

  • it has linkage;

  • it is referenced;

  • all references to it are in the same function; and

  • if it has external linkage, then all references are in the same unit.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.10

Aliases

MC3.R8.10, MC3R2.R8.10, MC3A4.R8.10, MC3A3.R8.10, MC3C2.R8.10, MC3A2.R8.10, MC3R1.R8.10, MC3C1.R8.10, MC3A1.R8.10, MC3R0.R8.10

Summary

An inline function shall be declared with the static storage class. (See page 80 of MISRA-C-2012 [45] , page 81 of MISRA-C-2012-Revision-1 [51] , page 91 of MISRA-C-2023 [58] , page 91 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.11

Aliases

MC3.R8.11, MC3R2.R8.11, MC3A4.R8.11, MC3A3.R8.11, MC3C2.R8.11, MC3A2.R8.11, MC3R1.R8.11, MC3C1.R8.11, MC3A1.R8.11, MC3R0.R8.11

Summary

When an array with external linkage is declared, its size should be explicitly specified. (See page 80 of MISRA-C-2012 [45] , page 81 of MISRA-C-2012-Revision-1 [51] , page 92 of MISRA-C-2023 [58] , page 92 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.12

Aliases

MC3.R8.12, MC3R2.R8.12, MC3A4.R8.12, MC3A3.R8.12, MC3C2.R8.12, MC3A2.R8.12, MC3R1.R8.12, MC3C1.R8.12, MC3A1.R8.12, MC3R0.R8.12

Summary

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique. (See page 81 of MISRA-C-2012 [45] , page 82 of MISRA-C-2012-Revision-1 [51] , page 92 of MISRA-C-2023 [58] , page 92 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R8.13

Aliases

MC3.R8.13, MC3R2.R8.13, MC3A4.R8.13, MC3A3.R8.13, MC3C2.R8.13, MC3A2.R8.13, MC3R1.R8.13, MC3C1.R8.13, MC3A1.R8.13, MC3R0.R8.13

Summary

A pointer should point to a const-qualified type whenever possible. (See page 81 of MISRA-C-2012 [45] , page 82 of MISRA-C-2012-Revision-1 [51] , page 93 of MISRA-C-2023 [58] , page 93 of MISRA-C-2025 [59] .)

Description

Notes:

  • Any pointer that is not used to modify the addressed object must be declared as pointer to const

  • Similarly, any array whose elements are not modified must declare the elements as const.

  • The parameters for any functions such as main that have a fixed signature are ignored.

  • To specify that an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const, use the single_assign service configuration.

  • To restrict the declarations that are shown, use the show_declarations service configuration.

For example, the following configure line will restrict the reporting to variable and function definitions:

-doc="Only variable and function definitions are interesting."
-config=MC4.R8.13,show_declarations,none

Imprecision

False negatives are present because the single unit analyzer does not check pointers with program scope.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=MC4.R8.13,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=MC4.R8.13,show_declarations=all

Option single_assign
single_assign
-config=MC4.R8.13,single_assign=BOOL

Specify if an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const.

BOOL:

boolean. Accepted values are:

  • true: an uninitialized local variable declaration with a single assignment will be considered for converting the constness to const;

  • false: an uninitialized local variable declaration with a single assignment will not be considered for converting the constness to const;

Default:

-config=MC4.R8.13,single_assign=false

Option declarations
declarations
-config=MC4.R8.13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MC4.R8.13,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MC4.R8.13,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MC4.R8.14

Aliases

MC3.R8.14, MC3R2.R8.14, MC3A4.R8.14, MC3A3.R8.14, MC3C2.R8.14, MC3A2.R8.14, MC3R1.R8.14, MC3C1.R8.14, MC3A1.R8.14, MC3R0.R8.14

Summary

The restrict type qualifier shall not be used. (See page 83 of MISRA-C-2012 [45] , page 84 of MISRA-C-2012-Revision-1 [51] , page 94 of MISRA-C-2023 [58] , page 94 of MISRA-C-2025 [59] , page 16 of MISRA-C-2012-Permits-1 [53] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.14,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.15

Aliases

MC3.R8.15, MC3R2.R8.15, MC3A4.R8.15, MC3A3.R8.15

Summary

All declarations of an object with an explicit alignment specification shall specify the same alignment. (See page 18 of MISRA-C-2012-Amendment-3 [55] , page 95 of MISRA-C-2023 [58] , page 95 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.15,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.16

Aliases

MC3.R8.16, MC3R2.R8.16, MC3A4.R8.16, MC3A3.R8.16

Summary

The alignment specification of zero should not appear in an object declaration. (See page 20 of MISRA-C-2012-Amendment-3 [55] , page 96 of MISRA-C-2023 [58] , page 96 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.16,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.17

Aliases

MC3.R8.17, MC3R2.R8.17, MC3A4.R8.17, MC3A3.R8.17

Summary

At most one explicit alignment specifier should appear in an object declaration. (See page 20 of MISRA-C-2012-Amendment-3 [55] , page 97 of MISRA-C-2023 [58] , page 97 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.17,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.18

Aliases

Summary

There shall be no tentative definitions in a header file. (See page 95 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.18,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R8.19

Aliases

Summary

There shall be no external declarations in a source file. (See page 96 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R8.19,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3A3.R9.1

Aliases

MC3C2.R9.1, MC3A2.R9.1, MC3R1.R9.1, MC3C1.R9.1, MC3A1.R9.1, MC3R0.R9.1

Summary

The value of an object with automatic storage duration shall not be read before it has been set. (See page 83 of MISRA-C-2012 [45] , page 84 of MISRA-C-2012-Revision-1 [51] .)

Description

Notes:

  • An automatic variable does not need to be initialized at the declaration, but a value must be written to it before it is used.

  • Initializing any one member of a union is not considered as (proper) initialization of the other members.

  • To specify the read and write properties for the called functions use the -call_properties global configuration with properties pointee_read and pointee_write for the read and write properties of non-const parameters and const_pointee_read and const_pointee_write for the read and write properties of const parameters.

For example, with the configuration line:

-call_properties+={"decl(name(gettimeofday))",
{"pointee_read(1..=never)",
"pointee_write(1..=always)"}}

the first argument in a call to the function gettimeofday is not reported for not being initialized and, after the call, it is assumed that the first argument has been initialized.

Implementation

Reports if an automatic variable may be used without initialization.

Imprecision

Cautions are reported when the checker cannot determine the necessary execution order or whether all the components of a data structure have been initialized.

  • Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}
  • In the presence of backward or sideways jumps, the results are unreliable.

int p(int y) {
  int x;
  int i = 0;
loop:
  if (i < y) {
    if (i > 0) {
      return x;
    }
    x = 4;
    ++i;
    goto loop;
  }
  return 0;
}

There may be false positives when there are backward goto jumps or when the goto jumps break the control structures.

Configuration

See generic service options.

Option member_areas
member_areas
-config=MC3A3.R9.1,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=MC3A3.R9.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MC3A3.R9.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R9.1

Aliases

MC3.R9.1, MC3R2.R9.1, MC3A4.R9.1

Summary

The value of an object with automatic storage duration shall not be read before it has been set. (See page 42 of MISRA-C-2012-Amendment-4 [57] , page 98 of MISRA-C-2023 [58] , page 98 of MISRA-C-2025 [59] .)

Description

Notes:

  • An automatic variable does not need to be initialized at the declaration, but a value must be written to it before it is used.

  • Initializing any one member of a union is not considered as (proper) initialization of the other members.

  • To specify the read and write properties for the called functions use the -call_properties global configuration with properties pointee_read and pointee_write for the read and write properties of non-const parameters and const_pointee_read and const_pointee_write for the read and write properties of const parameters.

For example, with the configuration line:

-call_properties+={"decl(name(gettimeofday))",
{"pointee_read(1..=never)",
"pointee_write(1..=always)"}}

the first argument in a call to the function gettimeofday is not reported for not being initialized and, after the call, it is assumed that the first argument has been initialized.

Implementation

Reports if an automatic variable may be used without initialization.

Imprecision

Cautions are reported when the checker cannot determine the necessary execution order or whether all the components of a data structure have been initialized.

  • Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}
  • In the presence of backward or sideways jumps, the results are unreliable.

int p(int y) {
  int x;
  int i = 0;
loop:
  if (i < y) {
    if (i > 0) {
      return x;
    }
    x = 4;
    ++i;
    goto loop;
  }
  return 0;
}

There may be false positives when there are backward goto jumps or when the goto jumps break the control structures.

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC4.R9.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

Default:

-config=MC4.R9.1,ignored_decls="type(node(atomic))"

Option member_areas
member_areas
-config=MC4.R9.1,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=MC4.R9.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R9.2

Aliases

MC3.R9.2, MC3R2.R9.2, MC3A4.R9.2, MC3A3.R9.2, MC3C2.R9.2, MC3A2.R9.2, MC3R1.R9.2, MC3C1.R9.2, MC3A1.R9.2, MC3R0.R9.2

Summary

The initializer for an aggregate or union shall be enclosed in braces. (See page 85 of MISRA-C-2012 [45] , page 86 of MISRA-C-2012-Revision-1 [51] , page 99 of MISRA-C-2023 [58] , page 99 of MISRA-C-2025 [59] , page 16 of MISRA-C-2012-Permits-1 [53] .)

Description

Notes:

  • zero initialization is compliant;

  • lengths of array initializers are not checked;

  • braces used (or missing) for designated initial values are checked.

Configuration

See generic service options.

Rule MC4.R9.3

Aliases

MC3.R9.3, MC3R2.R9.3, MC3A4.R9.3, MC3A3.R9.3, MC3C2.R9.3, MC3A2.R9.3, MC3R1.R9.3, MC3C1.R9.3, MC3A1.R9.3, MC3R0.R9.3

Summary

Arrays shall not be partially initialized. (See page 86 of MISRA-C-2012 [45] , page 87 of MISRA-C-2012-Revision-1 [51] , page 100 of MISRA-C-2023 [58] , page 100 of MISRA-C-2025 [59] , page 17 of MISRA-C-2012-Permits-1 [53] .)

Description

Notes:

  • zero initialization is compliant;

  • a sparse initialization using only designators is compliant;

  • strings used for string literal initialization are compliant and the length is not checked;

Configuration

See generic service options.

Rule MC4.R9.4

Aliases

MC3.R9.4, MC3R2.R9.4, MC3A4.R9.4, MC3A3.R9.4, MC3C2.R9.4, MC3A2.R9.4, MC3R1.R9.4, MC3C1.R9.4, MC3A1.R9.4, MC3R0.R9.4

Summary

An element of an object shall not be initialized more than once. (See page 87 of MISRA-C-2012 [45] , page 88 of MISRA-C-2012-Revision-1 [51] , page 20 of MISRA-C-2012-Amendment-2 [52] , page 101 of MISRA-C-2023 [58] , page 101 of MISRA-C-2025 [59] .)

Description

When the initial value that is being overridden has been explicitly specified, then the initialization is reported as a violation.

Other instances of possibly overriding initializers are reported as cautions.

Imprecision

Cautions are reported when an initializer includes both a multi-level designator and a single-level or non-designator initializer at the same sub-object level. In such cases, only the first designated and the first non-designated initializers at that level are shown as evidence.

Configuration

See generic service options.

Rule MC4.R9.5

Aliases

MC3.R9.5, MC3R2.R9.5, MC3A4.R9.5, MC3A3.R9.5, MC3C2.R9.5, MC3A2.R9.5, MC3R1.R9.5, MC3C1.R9.5, MC3A1.R9.5, MC3R0.R9.5

Summary

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly. (See page 88 of MISRA-C-2012 [45] , page 89 of MISRA-C-2012-Revision-1 [51] , page 20 of MISRA-C-2012-Amendment-2 [52] , page 103 of MISRA-C-2023 [58] , page 103 of MISRA-C-2025 [59] , page 17 of MISRA-C-2012-Permits-1 [53] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R9.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R9.6

Aliases

MC3.R9.6, MC3R2.R9.6, MC3A4.R9.6

Summary

An initializer using chained designators shall not contain initializers without designators. (See page 15 of MISRA-C-2012-Amendment-4 [57] , page 104 of MISRA-C-2023 [58] , page 104 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R9.7

Aliases

MC3.R9.7, MC3R2.R9.7, MC3A4.R9.7

Summary

Atomic objects shall be appropriately initialized before being accessed. (See page 17 of MISRA-C-2012-Amendment-4 [57] , page 105 of MISRA-C-2023 [58] , page 105 of MISRA-C-2025 [59] .)

Description

the service ignores any uses of threads and assumes the header threads.h is not included

Imprecision

False positives are possible due to the undecidability of the rule

Reports some instances of automatic atomic variables whose correct initialization cannot be proved by the analyzer (e.g., a variable declared and then initialized after a block of code that contains non-trivial branches and/or loops)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R9.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3A1.R10.1

Aliases

MC3R0.R10.1

Summary

Operands shall not be of an inappropriate essential type. (See page 90 of MISRA-C-2012 [45] , page 17 of MISRA-C-2012-Permits-1 [53] .)

Description

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

unsigned foo(unsigned x) {
  return x | 1;
}

the service will report as a violation the x signed integer used as unsigned integer. However, with the following configuration line the report will be deviated:

-doc="The value-preserving conversions of integer constants are safe."
-config=MC3A1.R10.1,etypes={safe,"any()","preserved_integer_constant()"}

Exceptions

  • A non-negative integer constant expression of essentially signed type may be used as the right-hand operand of a shift operator.

Configuration

See generic service options.

Option etypes
etypes
-config=MC3A1.R10.1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC3C2.R10.1

Aliases

MC3A2.R10.1, MC3R1.R10.1, MC3C1.R10.1

Summary

Operands shall not be of an inappropriate essential type. (See page 91 of MISRA-C-2012-Revision-1 [51] , page 9 of MISRA-C-2012-TC1 [48] , page 13 of MISRA-C-2012-TC2 [54] , page 17 of MISRA-C-2012-Permits-1 [53] .)

Description

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

unsigned foo(unsigned x) {
  return x | 1;
}

the service will report as a violation the x signed integer used as unsigned integer. However, with the following configuration line the report will be deviated:

-doc="The value-preserving conversions of integer constants are safe."
-config=MC3C2.R10.1,etypes={safe,"any()","preserved_integer_constant()"}

Exceptions

  • A non-negative integer constant expression of essentially signed type may be used as the right-hand operand of a shift operator.

Configuration

See generic service options.

Option etypes
etypes
-config=MC3C2.R10.1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC3.R10.1

Aliases

MC3R2.R10.1, MC3A4.R10.1, MC3A3.R10.1

Summary

Operands shall not be of an inappropriate essential type. (See page 22 of MISRA-C-2012-Amendment-3 [55] , page 108 of MISRA-C-2023 [58] , page 108 of MISRA-C-2025 [59] , page 17 of MISRA-C-2012-Permits-1 [53] .)

Description

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

unsigned foo(unsigned x) {
  return x | 1;
}

the service will report as a violation the x signed integer used as unsigned integer. However, with the following configuration line the report will be deviated:

-doc="The value-preserving conversions of integer constants are safe."
-config=MC3.R10.1,etypes={safe,"any()","preserved_integer_constant()"}

Exceptions

  • A non-negative integer constant expression of essentially signed type may be used as the right-hand operand of a shift operator.

Configuration

See generic service options.

Option statements
statements
-config=MC3.R10.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option etypes
etypes
-config=MC3.R10.1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.1

Aliases

Summary

Operands shall not be of an inappropriate essential type. (See page 108 of MISRA-C-2025 [59] , page 17 of MISRA-C-2012-Permits-1 [53] .)

Description

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

unsigned foo(unsigned x) {
  return x | 1;
}

the service will report as a violation the x signed integer used as unsigned integer. However, with the following configuration line the report will be deviated:

-doc="The value-preserving conversions of integer constants are safe."
-config=MC4.R10.1,etypes={safe,"any()","preserved_integer_constant()"}

Exceptions

  • A non-negative integer constant expression of essentially signed type may be used as the right-hand operand of a shift operator.

Configuration

See generic service options.

Option statements
statements
-config=MC4.R10.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option etypes
etypes
-config=MC4.R10.1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.2

Aliases

MC3.R10.2, MC3R2.R10.2, MC3A4.R10.2, MC3A3.R10.2, MC3C2.R10.2, MC3A2.R10.2, MC3R1.R10.2, MC3C1.R10.2, MC3A1.R10.2, MC3R0.R10.2

Summary

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations. (See page 93 of MISRA-C-2012 [45] , page 94 of MISRA-C-2012-Revision-1 [51] , page 13 of MISRA-C-2012-TC2 [54] , page 111 of MISRA-C-2023 [58] , page 111 of MISRA-C-2025 [59] .)

Description

Operands are used inappropriately if:

  • the operator is + and one of the operands has an essentially character type whereas the other does not have an essentially signed or unsigned type with rank less than or equal to that of int;

  • the operator is - and the first operand has an essentially character type whereas the second does not have an essentially signed, unsigned or character type with rank less than or equal to that of int; or

  • the operator is - and the second operand has an essentially character type whereas the first does not have an essentially character type.

Note that reports about essential types can be tagged using the etypes service configuration.

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R10.2,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.3

Aliases

MC3.R10.3, MC3R2.R10.3, MC3A4.R10.3, MC3A3.R10.3, MC3C2.R10.3, MC3A2.R10.3, MC3R1.R10.3, MC3C1.R10.3, MC3A1.R10.3, MC3R0.R10.3

Summary

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category. (See page 94 of MISRA-C-2012 [45] , page 95 of MISRA-C-2012-Revision-1 [51] , page 9 of MISRA-C-2012-TC1 [48] , page 14 of MISRA-C-2012-TC2 [54] , page 23 of MISRA-C-2012-Amendment-3 [55] , page 112 of MISRA-C-2023 [58] , page 112 of MISRA-C-2025 [59] , page 18 of MISRA-C-2012-Permits-1 [53] .)

Description

It is reported if an expression’s value is assigned, copied or converted to an object with a narrower essential type or of a different essential type category when performing any of the following operations:

  • using an assignment operator,

  • passing an argument in a function call,

  • returning an expression from a function,

  • initializing an object,

  • converting a constant expression in a switch label case statement to the promoted type of the controlling expression.

Notes:

  • The first four items are from the specification of assignment on page 310 of MISRA C:2023 [58] , Appendix J.

  • Reports about essential types can be tagged using the etypes service configuration. For example, with the code:

void g(unsigned);
int i = 42;
void f() { g(i); }

The service will report as a violation the function call argument i. However, with the following configuration line the report will be deviated:

-doc='Invocations of function "g" with non-negative signed integer values are safe.'
-config=MC4.R10.3,etypes+={safe,"stmt(call(name(g)))","any()"}

Exceptions

The allowed exceptions are:

  • A non-negative integer constant expression of essentially signed type with rank less than or equal to int may be assigned to an object of essentially unsigned type if its value can be represented in that type;

  • an aggregate or union type may use the zero initializer {0};

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R10.3,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.4

Aliases

MC3.R10.4, MC3R2.R10.4, MC3A4.R10.4, MC3A3.R10.4, MC3C2.R10.4, MC3A2.R10.4, MC3R1.R10.4, MC3C1.R10.4, MC3A1.R10.4, MC3R0.R10.4

Summary

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category. (See page 95 of MISRA-C-2012 [45] , page 96 of MISRA-C-2012-Revision-1 [51] , page 10 of MISRA-C-2012-TC1 [48] , page 20 of MISRA-C-2012-Amendment-2 [52] , page 24 of MISRA-C-2012-Amendment-3 [55] , page 114 of MISRA-C-2023 [58] , page 114 of MISRA-C-2025 [59] , page 18 of MISRA-C-2012-Permits-1 [53] .)

Description

For usual arithmetic conversions, see the C90 standard [34] Section 6.2.1.5 and the C99 standard [37] Section 6.3.1.8).

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

void f(int x) {
  unsigned int i;
  i = (x > 0) ? 42: i;
}

The service will report as violations the operands to the binary conditional operator. However, with the following configuration line the report will be deviated:

-doc="The value-preserving conversions of integer constants are safe."
-config=MC4.R10.4,etypes={safe, "any()", "preserved_integer_constant()"}

Exceptions

The following exceptions are allowed:

  • the binary + and += operators may have one operator with essentially character type if the other operator has an essentially signed or unsigned type;

  • the binary - and -= operators may have their left-hand operator with essentially character type if the other operator has an essentially signed or unsigned type.

  • the operators may have one operand with essentially real floating type and the other operand with essentially complex floating type. In the case of the conditional operator, the exception applies to the second and third operands.

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R10.4,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.5

Aliases

MC3.R10.5, MC3R2.R10.5, MC3A4.R10.5, MC3A3.R10.5, MC3C2.R10.5, MC3A2.R10.5, MC3R1.R10.5, MC3C1.R10.5, MC3A1.R10.5, MC3R0.R10.5

Summary

The value of an expression should not be cast to an inappropriate essential type. (See page 97 of MISRA-C-2012 [45] , page 98 of MISRA-C-2012-Revision-1 [51] , page 11 of MISRA-C-2012-TC1 [48] , page 21 of MISRA-C-2012-Amendment-2 [52] , page 24 of MISRA-C-2012-Amendment-3 [55] , page 115 of MISRA-C-2023 [58] , page 115 of MISRA-C-2025 [59] .)

Description

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

#include <stdbool.h>
void f() { _Bool b = ( _Bool ) 3U; }

The service will report as a violation the cast to type _Bool. However, with the following configuration line the report will be deviated:

-doc="Programmers have been educated on how conversions to booleans work, no developer confusion possible."
-config=MC4.R10.5,etypes={safe, "any()", "dst_type(boolean)"}

Exceptions

An integer constant expression with value 0 or 1 and either essentially signed or essentially unsigned type may be cast to an essentially boolean type.

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R10.5,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.6

Aliases

MC3.R10.6, MC3R2.R10.6, MC3A4.R10.6, MC3A3.R10.6, MC3C2.R10.6, MC3A2.R10.6, MC3R1.R10.6, MC3C1.R10.6, MC3A1.R10.6, MC3R0.R10.6

Summary

The value of a composite expression shall not be assigned to an object with wider essential type. (See page 99 of MISRA-C-2012 [45] , page 100 of MISRA-C-2012-Revision-1 [51] , page 117 of MISRA-C-2023 [58] , page 117 of MISRA-C-2025 [59] , page 19 of MISRA-C-2012-Permits-1 [53] .)

Description

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

unsigned foo(unsigned short u16)
{
  unsigned u32;
  u32 = u16 + u16;
  // ...
  return u32;
}

The service will report as a violation the assignment. However, with the following configuration line the report will be deviated:

-doc="Types involved in assignement of unsigned int values are often fixed and cannot be changed."
-config=MC4.R10.6,etypes+={safe,
  "stmt(operator(assign))",
  "sibling(rhs, src_expr(type(builtin(unsigned int))))"}

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R10.6,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.7

Aliases

MC3.R10.7, MC3R2.R10.7, MC3A4.R10.7, MC3A3.R10.7, MC3C2.R10.7, MC3A2.R10.7, MC3R1.R10.7, MC3C1.R10.7, MC3A1.R10.7, MC3R0.R10.7

Summary

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type. (See page 99 of MISRA-C-2012 [45] , page 100 of MISRA-C-2012-Revision-1 [51] , page 24 of MISRA-C-2012-Amendment-3 [55] , page 118 of MISRA-C-2023 [58] , page 118 of MISRA-C-2025 [59] , page 19 of MISRA-C-2012-Permits-1 [53] .)

Description

For usual arithmetic conversions, see page 283 of MISRA C:2023 [58] , Appendix D.

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

void foo(void)
{
  unsigned short u16a, u16b;
  unsigned u32;
  u32 = (u16a + u16b) + u32;
}

The service will report as a violation the addition operators. However, with the following configuration line the report will be hidden:

-doc="Types involved in expressions on integer values are often fixed and cannot be changed."
-config=MC4.R10.7,etypes+={safe,
"stmt(type(integral()))",
"src_type(integer)&&dst_type(integer)"}

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R10.7,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R10.8

Aliases

MC3.R10.8, MC3R2.R10.8, MC3A4.R10.8, MC3A3.R10.8, MC3C2.R10.8, MC3A2.R10.8, MC3R1.R10.8, MC3C1.R10.8, MC3A1.R10.8, MC3R0.R10.8

Summary

The value of a composite expression shall not be cast to a different essential type category or a wider essential type. (See page 100 of MISRA-C-2012 [45] , page 101 of MISRA-C-2012-Revision-1 [51] , page 12 of MISRA-C-2012-TC1 [48] , page 25 of MISRA-C-2012-Amendment-3 [55] , page 119 of MISRA-C-2023 [58] , page 119 of MISRA-C-2025 [59] , page 20 of MISRA-C-2012-Permits-1 [53] .)

Description

A composite expression is reported if it is cast to a wider type or a type in a different category.

Note that reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

void f(void) {
  signed int d = 1;
  signed long long int x;
  x = (signed long long int) (d + d);
}

The service will report as a violation the cast operator. However, with the following configuration line the report will be deviated:

-doc="Casts from signed integer types to wider essential types are allowed."
-config=MC4.R10.8,etypes+={safe, "any()",
   "src_type(signed)&&!dst_type(signed_small)"}

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R10.8,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R11.1

Aliases

MC3.R11.1, MC3R2.R11.1, MC3A4.R11.1, MC3A3.R11.1, MC3C2.R11.1, MC3A2.R11.1, MC3R1.R11.1, MC3C1.R11.1, MC3A1.R11.1, MC3R0.R11.1

Summary

Conversions shall not be performed between a pointer to a function and any other type. (See page 101 of MISRA-C-2012 [45] , page 102 of MISRA-C-2012-Revision-1 [51] , page 21 of MISRA-C-2012-Amendment-2 [52] , page 121 of MISRA-C-2023 [58] , page 121 of MISRA-C-2025 [59] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Implicit conversions."
-config=MC4.R11.1,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MC4.R11.1,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option casts
casts
-config=MC4.R11.1,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC4.R11.2

Aliases

MC3.R11.2, MC3R2.R11.2, MC3A4.R11.2, MC3A3.R11.2, MC3C2.R11.2, MC3A2.R11.2, MC3R1.R11.2, MC3C1.R11.2, MC3A1.R11.2, MC3R0.R11.2

Summary

Conversions shall not be performed between a pointer to an incomplete type and any other type. (See page 103 of MISRA-C-2012 [45] , page 104 of MISRA-C-2012-Revision-1 [51] , page 12 of MISRA-C-2012-TC1 [48] , page 122 of MISRA-C-2023 [58] , page 122 of MISRA-C-2025 [59] .)

Description

Notes:

  • This rule applies to the unqualified types that are pointed to by the pointers.

  • Conversions from or to a pointer to void are allowed.

  • Reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration line:

-doc="Static casts."
-config=MC4.R11.2,casts={static_cast, "class(static)"}

reports concerning static named casts will have the tag static_cast.

Exceptions

  • A conversion from a null pointer constant to a pointer to an incomplete type is allowed.

  • A conversion from a pointer to an incomplete type to void is allowed.

Configuration

See generic service options.

Option casts
casts
-config=MC4.R11.2,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC3A3.R11.3

Aliases

MC3C2.R11.3, MC3A2.R11.3, MC3R1.R11.3, MC3C1.R11.3, MC3A1.R11.3, MC3R0.R11.3

Summary

A cast shall not be performed between a pointer to object type and a pointer to a different object type. (See page 104 of MISRA-C-2012 [45] , page 105 of MISRA-C-2012-Revision-1 [51] , page 21 of MISRA-C-2012-Amendment-2 [52] , page 14 of MISRA-C-2012-TC2 [54] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration line:

-doc="Casts from a pointer to a pointer with the same pointee type, ignoring any qualifications."
-config=MC3A3.R11.3,casts={same_unqualified,
                         "relation(same_unqualified_pointee)"}

reports concerning the conversions between types that are the same except for their qualification, will have the tag same_unqualified.

Configuration

See generic service options.

Option casts
casts
-config=MC3A3.R11.3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC4.R11.3

Aliases

MC3.R11.3, MC3R2.R11.3, MC3A4.R11.3

Summary

A conversion shall not be performed between a pointer to object type and a pointer to a different object type. (See page 18 of MISRA-C-2012-Amendment-4 [57] , page 123 of MISRA-C-2023 [58] , page 123 of MISRA-C-2025 [59] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration line:

-doc="Casts from a pointer to a pointer with the same pointee type, ignoring any qualifications."
-config=MC4.R11.3,casts={same_unqualified,
                         "relation(same_unqualified_pointee)"}

reports concerning the conversions between types that are the same except for their qualification, will have the tag same_unqualified.

Configuration

See generic service options.

Option casts
casts
-config=MC4.R11.3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC3.R11.4

Aliases

MC3R2.R11.4, MC3A4.R11.4, MC3A3.R11.4, MC3C2.R11.4, MC3A2.R11.4, MC3R1.R11.4, MC3C1.R11.4, MC3A1.R11.4, MC3R0.R11.4

Summary

A conversion should not be performed between a pointer to object and an integer type. (See page 105 of MISRA-C-2012 [45] , page 106 of MISRA-C-2012-Revision-1 [51] , page 12 of MISRA-C-2012-TC1 [48] , page 21 of MISRA-C-2012-Amendment-2 [52] , page 124 of MISRA-C-2023 [58] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Implicit conversions."
-config=MC3.R11.4,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MC3.R11.4,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option cast_exception
cast_exception
-config=MC3.R11.4,cast_exception=EXCEPTION,...

Specify exceptions.

{EXCEPTION,…}:

exceptions allowed. Accepted members are:

  • CONDS: conditions for exceptions. Accepted forms are:

  • constant_pointee_align: allow an integral constant expression whose mod with destination pointee alignment is 0

  • stmt_matcher(STMT_MATCHER): allow any expression matching STMT_MATCHER (see the -stmt_selector global configuration)

Default:

-config=MC3.R11.4,cast_exception={}

Option casts
casts
-config=MC3.R11.4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC4.R11.4

Aliases

Summary

A conversion shall not be performed between a pointer to object and an arithmetic type. (See page 124 of MISRA-C-2025 [59] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Implicit conversions."
-config=MC4.R11.4,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MC4.R11.4,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option cast_exception
cast_exception
-config=MC4.R11.4,cast_exception=EXCEPTION,...

Specify exceptions.

{EXCEPTION,…}:

exceptions allowed. Accepted members are:

  • CONDS: conditions for exceptions. Accepted forms are:

  • constant_pointee_align: allow an integral constant expression whose mod with destination pointee alignment is 0

  • stmt_matcher(STMT_MATCHER): allow any expression matching STMT_MATCHER (see the -stmt_selector global configuration)

Default:

-config=MC4.R11.4,cast_exception={}

Option casts
casts
-config=MC4.R11.4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option etypes
etypes
-config=MC4.R11.4,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC3.R11.5

Aliases

MC3R2.R11.5, MC3A4.R11.5, MC3A3.R11.5, MC3C2.R11.5, MC3A2.R11.5, MC3R1.R11.5, MC3C1.R11.5, MC3A1.R11.5, MC3R0.R11.5

Summary

A conversion should not be performed from pointer to void into pointer to object. (See page 106 of MISRA-C-2012 [45] , page 107 of MISRA-C-2012-Revision-1 [51] , page 125 of MISRA-C-2023 [58] .)

Description

Notes:

  • A null pointer constant is the value 0, optionally cast to void (see Section 8.11, page 102 of MISRA C:2012 [45] ).

  • Reports for non-compliant conversions can be tagged using the casts service configuration.

For example, with the configuration lines:

-doc="Implicit conversions."
-config=MC3.R11.5,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MC3.R11.5,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option cast_exception
cast_exception
-config=MC3.R11.5,cast_exception=EXCEPTION,...

Specify exceptions.

{EXCEPTION,…}:

exceptions allowed. Accepted members are:

  • CONDS: conditions for exceptions. Accepted forms are:

  • constant_pointee_align: allow an integral constant expression whose mod with destination pointee alignment is 0

  • stmt_matcher(STMT_MATCHER): allow any expression matching STMT_MATCHER (see the -stmt_selector global configuration)

Default:

-config=MC3.R11.5,cast_exception={}

Option casts
casts
-config=MC3.R11.5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC4.R11.5

Aliases

Summary

A conversion should not be performed from pointer to void into pointer to object. (See page 125 of MISRA-C-2025 [59] .)

Description

Notes:

  • A null pointer constant is the value 0, optionally cast to void (see Section 8.11, page 102 of MISRA C:2012 [45] ).

  • Reports for non-compliant conversions can be tagged using the casts service configuration.

For example, with the configuration lines:

-doc="Implicit conversions."
-config=MC4.R11.5,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MC4.R11.5,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option cast_exception
cast_exception
-config=MC4.R11.5,cast_exception=EXCEPTION,...

Specify exceptions.

{EXCEPTION,…}:

exceptions allowed. Accepted members are:

  • CONDS: conditions for exceptions. Accepted forms are:

  • constant_pointee_align: allow an integral constant expression whose mod with destination pointee alignment is 0

  • stmt_matcher(STMT_MATCHER): allow any expression matching STMT_MATCHER (see the -stmt_selector global configuration)

Default:

-config=MC4.R11.5,cast_exception={}

Option casts
casts
-config=MC4.R11.5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC3.R11.6

Aliases

MC3R2.R11.6, MC3A4.R11.6, MC3A3.R11.6, MC3C2.R11.6, MC3A2.R11.6, MC3R1.R11.6, MC3C1.R11.6, MC3A1.R11.6, MC3R0.R11.6

Summary

A cast shall not be performed between pointer to void and an arithmetic type. (See page 107 of MISRA-C-2012 [45] , page 108 of MISRA-C-2012-Revision-1 [51] , page 14 of MISRA-C-2012-TC2 [54] , page 126 of MISRA-C-2023 [58] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Implicit conversions."
-config=MC3.R11.6,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MC3.R11.6,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option casts
casts
-config=MC3.R11.6,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC4.R11.6

Aliases

Summary

A cast shall not be performed between pointer to void and an arithmetic type. (See page 126 of MISRA-C-2025 [59] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Implicit conversions."
-config=MC4.R11.6,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MC4.R11.6,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option casts
casts
-config=MC4.R11.6,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC3.R11.7

Aliases

MC3R2.R11.7, MC3A4.R11.7, MC3A3.R11.7, MC3C2.R11.7, MC3A2.R11.7, MC3R1.R11.7, MC3C1.R11.7, MC3A1.R11.7, MC3R0.R11.7

Summary

A cast shall not be performed between pointer to object and a non-integer arithmetic type. (See page 107 of MISRA-C-2012 [45] , page 108 of MISRA-C-2012-Revision-1 [51] , page 127 of MISRA-C-2023 [58] .)

Description

Note that reports for non-compliant conversions can be tagged using the etypes service configuration.

For example, with the configuration lines:

-doc="Conversions due to explicit casts."
-config=MC3.R11.7,etypes={cast, "stmt(cast(!class(implicit)))", "any()"}

reports concerning the explicit casts will have the tag cast.

Configuration

See generic service options.

Option etypes
etypes
-config=MC3.R11.7,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC3A3.R11.8

Aliases

MC3C2.R11.8, MC3A2.R11.8, MC3R1.R11.8, MC3C1.R11.8, MC3A1.R11.8, MC3R0.R11.8

Summary

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer. (See page 108 of MISRA-C-2012 [45] , page 109 of MISRA-C-2012-Revision-1 [51] , page 21 of MISRA-C-2012-Amendment-2 [52] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Casts that remove the const qualifier."
-config=MC3A3.R11.8,casts={unqualify_const,
   "relation(unqualify_const_pointee)"}
-doc="Casts that remove the volatile qualifier."
-config=MC3A3.R11.8,casts={unqualify_volatile,
   "relation(unqualify_volatile_pointee)"}

reports concerning conversions that remove the const qualifier will have the tag unqualify_const while reports concerning conversions that remove the volatile qulifier will have the tag unqualify_volatile.

Configuration

See generic service options.

Option casts
casts
-config=MC3A3.R11.8,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC4.R11.8

Aliases

MC3.R11.8, MC3R2.R11.8, MC3A4.R11.8

Summary

A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer. (See page 18 of MISRA-C-2012-Amendment-4 [57] , page 128 of MISRA-C-2023 [58] , page 128 of MISRA-C-2025 [59] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Casts that remove the const qualifier."
-config=MC4.R11.8,casts={unqualify_const,
   "relation(unqualify_const_pointee)"}
-doc="Casts that remove the volatile qualifier."
-config=MC4.R11.8,casts={unqualify_volatile,
   "relation(unqualify_volatile_pointee)"}
-doc="Casts that remove the _Atomic qualifier."
-config=MC4.R11.8,casts={unqualify_atomic,
   "relation(unqualify_atomic_pointee)"}

reports concerning conversions that remove the const qualifier will have the tag unqualify_const; reports concerning conversions that remove the volatile qulifier will have the tag unqualify_volatile; reports concerning conversions that remove the _Atomic qualifier will have the tag unqualify_atomic.

Configuration

See generic service options.

Option casts
casts
-config=MC4.R11.8,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC3A1.R11.9

Aliases

MC3R0.R11.9

Summary

The macro NULL shall be the only permitted form of integer null pointer constant. (See page 109 of MISRA-C-2012 [45] , page 20 of MISRA-C-2012-Permits-1 [53] .)

Exceptions

There is one exception:

  • a null pointer of the form (void *)0 is allowed.

Configuration

See generic service options.

Rule MC4.R11.9

Aliases

MC3.R11.9, MC3R2.R11.9, MC3A4.R11.9, MC3A3.R11.9, MC3C2.R11.9, MC3A2.R11.9, MC3R1.R11.9, MC3C1.R11.9

Summary

The macro NULL shall be the only permitted form of integer null pointer constant. (See page 13 of MISRA-C-2012-TC1 [48] , page 110 of MISRA-C-2012-Revision-1 [51] , page 129 of MISRA-C-2023 [58] , page 129 of MISRA-C-2025 [59] , page 20 of MISRA-C-2012-Permits-1 [53] .)

Exceptions

There are 2 exceptions:

  • a null pointer of the form (void *)0 is allowed;

  • shorthand zero initialization of an aggregate or union type containing pointers is compliant.

Configuration

See generic service options.

Rule MC4.R11.10

Aliases

MC3.R11.10, MC3R2.R11.10, MC3A4.R11.10

Summary

The _Atomic qualifier shall not be applied to the incomplete type void. (See page 19 of MISRA-C-2012-Amendment-4 [57] , page 130 of MISRA-C-2023 [58] , page 130 of MISRA-C-2025 [59] .)

Description

The use of void with the _Atomic qualifier causes a B.PARSER error, therefore any non-compliant use is evidenced by the presence of such error

Configuration

See generic service options.

Rule MC4.R11.11

Aliases

Summary

Pointers shall not be implicitly compared to NULL. (See page 130 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option casts
casts
-config=MC4.R11.11,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option etypes
etypes
-config=MC4.R11.11,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R12.1

Aliases

MC3.R12.1, MC3R2.R12.1, MC3A4.R12.1, MC3A3.R12.1, MC3C2.R12.1, MC3A2.R12.1, MC3R1.R12.1, MC3C1.R12.1, MC3A1.R12.1, MC3R0.R12.1

Summary

The precedence of operators within expressions should be made explicit. (See page 111 of MISRA-C-2012 [45] , page 112 of MISRA-C-2012-Revision-1 [51] , page 21 of MISRA-C-2012-Amendment-2 [52] , page 131 of MISRA-C-2023 [58] , page 131 of MISRA-C-2025 [59] .)

Description

Reports an expression if any of the following hold:

  • the operand of sizeof or _Alignof is not in parentheses;

  • the precedence P of the main operator is between 3 and 12 and the precedence of the operand is strictly greater than P and no more than 12.

Note that the following operators and their precedences (as written in the MISRA C document) are assumed:

12 Multiplicative  * / %
11 Additive        + -
10 Bitwise Shift   << >>
9  Relational      < <= > >=
8  Equality        == !=
7  Bitwise AND     &
6  Bitwise XOR     ^
5  Bitwise OR      |
4  Logical AND     &&
3  Logical OR      ||

The trusted_pairs service configuration can be used to specify report tags for selected pairs of operators where the first matches the expression’s main operator and the second matches an operator of one of its operands. For example:

-doc="Programmers are aware of the precedence between relational and arithmetic operators, no developer confusion possible."
-config=MC4.R12.1,trusted_pairs={safe, relational:arithmetic}

will deviate reports for expressions such as a > b+c and b+c < a.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MC4.R12.1,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MC4.R12.2

Aliases

MC3.R12.2, MC3R2.R12.2, MC3A4.R12.2, MC3A3.R12.2, MC3C2.R12.2, MC3A2.R12.2, MC3R1.R12.2, MC3C1.R12.2, MC3A1.R12.2, MC3R0.R12.2

Summary

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand. (See page 113 of MISRA-C-2012 [45] , page 114 of MISRA-C-2012-Revision-1 [51] , page 133 of MISRA-C-2023 [58] , page 133 of MISRA-C-2025 [59] .)

Description

Any shift operator (<<, >>) is non-compliant if:

  • it is in the object sources and either the right-hand side is a non-constant expression or its value is a known constant value that is negative or is greater than or equal to the width in bits of the essential type of the left-hand side, or

  • it is in the non-skipped compiled file contents in a preprocessor conditional expressions and either the right-hand side is unexpanded or its value is negative or greater than or equal to the width in bits of the essential type of the left-hand side.

Imprecision

Cautions are reported when values on the right-hand side of shift operators have not been determined.

Configuration

See generic service options.

Rule MC4.R12.3

Aliases

MC3.R12.3, MC3R2.R12.3, MC3A4.R12.3, MC3A3.R12.3, MC3C2.R12.3, MC3A2.R12.3, MC3R1.R12.3, MC3C1.R12.3, MC3A1.R12.3, MC3R0.R12.3

Summary

The comma operator should not be used. (See page 114 of MISRA-C-2012 [45] , page 115 of MISRA-C-2012-Revision-1 [51] , page 134 of MISRA-C-2023 [58] , page 134 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R12.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R12.3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R12.4

Aliases

MC3.R12.4, MC3R2.R12.4, MC3A4.R12.4, MC3A3.R12.4, MC3C2.R12.4, MC3A2.R12.4, MC3R1.R12.4, MC3C1.R12.4, MC3A1.R12.4, MC3R0.R12.4

Summary

Evaluation of constant expressions should not lead to unsigned integer wrap-around. (See page 114 of MISRA-C-2012 [45] , page 115 of MISRA-C-2012-Revision-1 [51] , page 13 of MISRA-C-2012-TC1 [48] , page 134 of MISRA-C-2023 [58] , page 134 of MISRA-C-2025 [59] .)

Description

Any constant unsigned integer expression that leads to wrap-around is non-compliant if:

  • it is in the object sources and does not occur within the context of an explicit cast; or

  • it is in the non-skipped compiled file contents in a preprocessor conditional expression.

Note that this rule applies to expressions that satisfy the constraints and semantics for a constant expression, whether or not they appear in a context that requires a constant expression.

Configuration

See generic service options.

Rule MC4.R12.5

Aliases

MC3.R12.5, MC3R2.R12.5, MC3A4.R12.5, MC3A3.R12.5, MC3C2.R12.5, MC3A2.R12.5, MC3R1.R12.5, MC3C1.R12.5, MC3A1.R12.5

Summary

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”. (See page 11 of MISRA-C-2012-Amendment-1 [46] , page 117 of MISRA-C-2012-Revision-1 [51] , page 136 of MISRA-C-2023 [58] , page 136 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R12.5,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R12.5,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R12.6

Aliases

MC3.R12.6, MC3R2.R12.6, MC3A4.R12.6

Summary

Structure and union members of atomic objects shall not be directly accessed. (See page 20 of MISRA-C-2012-Amendment-4 [57] , page 137 of MISRA-C-2023 [58] , page 137 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R12.6,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R12.6,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R13.1

Aliases

MC3.R13.1, MC3R2.R13.1, MC3A4.R13.1, MC3A3.R13.1, MC3C2.R13.1, MC3A2.R13.1, MC3R1.R13.1, MC3C1.R13.1, MC3A1.R13.1, MC3R0.R13.1

Summary

Initializer lists shall not contain persistent side effects. (See page 116 of MISRA-C-2012 [45] , page 118 of MISRA-C-2012-Revision-1 [51] , page 138 of MISRA-C-2023 [58] , page 138 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported when the initializer is a call expression.

Configuration

See generic service options.

Option effects
effects
-config=MC4.R13.1,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC3A3.R13.2

Aliases

MC3C2.R13.2, MC3A2.R13.2, MC3R1.R13.2, MC3C1.R13.2, MC3A1.R13.2, MC3R0.R13.2

Summary

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders. (See page 117 of MISRA-C-2012 [45] , page 119 of MISRA-C-2012-Revision-1 [51] , page 14 of MISRA-C-2012-TC1 [48] , page 22 of MISRA-C-2012-Amendment-2 [52] , page 15 of MISRA-C-2012-TC2 [54] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule MC4.R13.2

Aliases

MC3.R13.2, MC3R2.R13.2, MC3A4.R13.2

Summary

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving. (See page 21 of MISRA-C-2012-Amendment-4 [57] , page 139 of MISRA-C-2023 [58] , page 139 of MISRA-C-2025 [59] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule MC4.R13.3

Aliases

MC3.R13.3, MC3R2.R13.3, MC3A4.R13.3, MC3A3.R13.3, MC3C2.R13.3, MC3A2.R13.3, MC3R1.R13.3, MC3C1.R13.3, MC3A1.R13.3, MC3R0.R13.3

Summary

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator. (See page 119 of MISRA-C-2012 [45] , page 121 of MISRA-C-2012-Revision-1 [51] , page 141 of MISRA-C-2023 [58] , page 141 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option effects
effects
-config=MC4.R13.3,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC4.R13.4

Aliases

MC3.R13.4, MC3R2.R13.4, MC3A4.R13.4, MC3A3.R13.4, MC3C2.R13.4, MC3A2.R13.4, MC3R1.R13.4, MC3C1.R13.4, MC3A1.R13.4, MC3R0.R13.4

Summary

The result of an assignment operator should not be used. (See page 120 of MISRA-C-2012 [45] , page 122 of MISRA-C-2012-Revision-1 [51] , page 143 of MISRA-C-2023 [58] , page 143 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R13.4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R13.4,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R13.5

Aliases

MC3.R13.5, MC3R2.R13.5, MC3A4.R13.5, MC3A3.R13.5, MC3C2.R13.5, MC3A2.R13.5, MC3R1.R13.5, MC3C1.R13.5, MC3A1.R13.5, MC3R0.R13.5

Summary

The right hand operand of a logical && or || operator shall not contain persistent side effects. (See page 121 of MISRA-C-2012 [45] , page 123 of MISRA-C-2012-Revision-1 [51] , page 144 of MISRA-C-2023 [58] , page 144 of MISRA-C-2025 [59] .)

Description

It is assumed that a call to a function has side effects unless the call is declared to have impact property const, pure or noeffect.

The -call_properties global configuration can be used to specify the call property. For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when the right operand is a call to a function not declared to be noeffect.

Configuration

See generic service options.

Option effects
effects
-config=MC4.R13.5,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC3A2.R13.6

Aliases

MC3R1.R13.6, MC3C1.R13.6, MC3A1.R13.6, MC3R0.R13.6

Summary

The operand of the sizeof operator shall not contain any expression which has potential side effects. (See page 122 of MISRA-C-2012 [45] , page 124 of MISRA-C-2012-Revision-1 [51] , page 22 of MISRA-C-2012-Amendment-2 [52] .)

Configuration

See generic service options.

Option effects
effects
-config=MC3A2.R13.6,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC4.R13.6

Aliases

MC3.R13.6, MC3R2.R13.6, MC3A4.R13.6, MC3A3.R13.6, MC3C2.R13.6

Summary

The operand of the sizeof operator shall not contain any expression which has potential side effects. (See page 15 of MISRA-C-2012-TC2 [54] , page 145 of MISRA-C-2023 [58] , page 145 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option effects
effects
-config=MC4.R13.6,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC4.R14.1

Aliases

MC3.R14.1, MC3R2.R14.1, MC3A4.R14.1, MC3A3.R14.1, MC3C2.R14.1, MC3A2.R14.1, MC3R1.R14.1, MC3C1.R14.1, MC3A1.R14.1, MC3R0.R14.1

Summary

A loop counter shall not have essentially floating type. (See page 125 of MISRA-C-2012 [45] , page 127 of MISRA-C-2012-Revision-1 [51] , page 147 of MISRA-C-2023 [58] , page 147 of MISRA-C-2025 [59] .)

Description

An expression with floating point type in an iteration statement is reported if:

  • it is modified, possibly monotonically, either in the body or, if the iteration statement is a for statement, in the third expression of the head; and

  • it is tested, either

    • in the condition part, or

    • in the condition part of a selection statement in the body of the iteration statement provided the body also has a possibly terminating statement such as break, return, throw or goto.

Imprecision

Cautions are reported when the analyzer is uncertain whether the loop counter conditions are fully satisfied.

Whether a variable, array element or member expression in an iteration statement is a loop counter, is undecidable.

So the rule reports a caution when the implementation is uncertain whether the loop counter conditions are fully satisfied for such an expression.

In some cases, the implementation of above constraints will lead to false cautions.

Configuration

See generic service options.

Rule MC4.R14.2

Aliases

MC3.R14.2, MC3R2.R14.2, MC3A4.R14.2, MC3A3.R14.2, MC3C2.R14.2, MC3A2.R14.2, MC3R1.R14.2, MC3C1.R14.2, MC3A1.R14.2, MC3R0.R14.2

Summary

A for loop shall be well-formed. (See page 126 of MISRA-C-2012 [45] , page 128 of MISRA-C-2012-Revision-1 [51] , page 14 of MISRA-C-2012-TC1 [48] , page 22 of MISRA-C-2012-Amendment-2 [52] , page 149 of MISRA-C-2023 [58] , page 149 of MISRA-C-2025 [59] , page 21 of MISRA-C-2012-Permits-1 [53] .)

Description

A well-formed for statement is defined in the MISRA C document.

However, to ensure a predictable number of iterations, we assume here a more restrictive definition:

  1. The three parts of the head of a for statement (refrerred to here, in the order in which they occur, as the before part, condition part and after part):

    • must all be empty; or

    • the before part is empty (and the loop counter should already be initialized) and the condition part and after parts are present or

    • all three parts must all be present.

Note that if the for statement has a non-compliant structure, then the report can be tagged using for_structure service configuration. For example:

-doc="for statements where the head has a non-empty condition part and an empty after part."
-config=MC4.R14.2,for_structure+=
    {my_struct_tag, "cond(non_empty)&&after(empty)"}

will tag the violation report for a for statement where the head has a non-empty condition part and an empty after part.

  1. In the following, a loop counter is defined to be any variable with scalar type that is referenced in the second expression of the head. For this rule, there must be a single loop counter that:

    • is a non-global variable,

    • is not be taken,

    • has a value changed monotonically on each iteration of the loop,

    • is not modified in the body.

Note that if the loop counter is non-compliant or there is more than one loop counter, then the report relating to this can be tagged using for_counter service configuration. For example:

-doc="for statements with more than one loop counter."
-config=MC4.R14.2,for_counter+={multi_tag, "!single()"}}

will tag the violation report for a for statement that has more than one loop counter.

  1. The three parts of the head must satisfy the following conditions:

    • the before part must only be used for defining and initialising the loop counter;

    • the cond part is such that

      • there are no side effects,

      • the loop counter is referenced,

      • any variable referenced here but maybe modified in the body must have a type that is essentially Boolean;

    • the after part must only modify the loop counter and must not refer to any variable that is modified in the body.

Note that if any of the parts of a for statement are non-compliant, then the report relating to the parts can be tagged using for_parts service configuration. For example:

-doc="for statements where the before part of the head initializes."
-config=MC4.R14.2,for_parts+={only_init_tag, "before(only_init)"}

will tag the violation report for a for statement when the before part of the head initializes (by means of assignments or definitions) more than one variable).

Imprecision

Cautions are reported when the analyzer cannot determine if all the conditions are fully satisfied.

Cautions are reported when:

  • the analyzer cannot determine if the loop counter will be monotonically incremented or decremented;

  • the analyzer cannot determine if a control variable that is not a loop counter and does not have Boolean type may be modified in the body;

  • the non-const address of a control variable is taken.

Configuration

See generic service options.

Option for_structure
for_structure
-config=MC4.R14.2,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=MC4.R14.2,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=MC4.R14.2,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MC3.R14.3

Aliases

MC3R2.R14.3, MC3A4.R14.3, MC3A3.R14.3, MC3C2.R14.3, MC3A2.R14.3, MC3R1.R14.3, MC3C1.R14.3, MC3A1.R14.3, MC3R0.R14.3

Summary

Controlling expressions shall not be invariant. (See page 127 of MISRA-C-2012 [45] , page 129 of MISRA-C-2012-Revision-1 [51] , page 16 of MISRA-C-2012-TC2 [54] , page 150 of MISRA-C-2023 [58] , page 150 of MISRA-C-2025 [59] , page 21 of MISRA-C-2012-Permits-1 [53] , page 22 of MISRA-C-2012-Permits-1 [53] , page 23 of MISRA-C-2012-Permits-1 [53] .)

Description

An expression is taken to be controlling if it is:

  • the condition part of the :? operator;

  • the condition part of an if, do, for, while or switch statement.

Notes:

  • expressions in a compile-time constant context are not reported;

  • if the condition for a while statement is the Boolean constant for true, then it is ignored;

  • if the condition for a do statement is the Boolean constant for false then it is also ignored;

  • observe that in the above allowed loop idioms, we have deliberately chosen to limit the controlling expressions of while-true and do-while-false loop idioms to Boolean constants. This is because the Exceptions on the MISRA C document allow any dowhile (evaluating either to a true value for Exception 1 and a false value for Exception 2);

  • other loop idioms can be added using the -loop_idioms global configuration;

  • in addition, reports for any statements with controlling expressions that have fixed values can be tagged using the statements service configuration.

Implementation

The rule only reports an expression if it can be detected that the expression will always have the same value.

Imprecision

False negatives are present because, in general, the fixed values of constant expressions may not be statically known.

Configuration

See generic service options.

Option statements
statements
-config=MC3.R14.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R14.3

Aliases

Summary

Controlling expressions shall not be invariant. (See page 150 of MISRA-C-2025 [59] , page 21 of MISRA-C-2012-Permits-1 [53] , page 22 of MISRA-C-2012-Permits-1 [53] , page 23 of MISRA-C-2012-Permits-1 [53] .)

Description

An expression is taken to be controlling if it is:

  • the condition part of the :? operator;

  • the condition part of an if, do, for, while or switch statement.

Notes:

  • expressions in a compile-time constant context are not reported;

  • if the condition for a while statement is the Boolean constant for true, then it is ignored;

  • if the condition for a do statement is the Boolean constant for false then it is also ignored;

  • observe that in the above allowed loop idioms, we have deliberately chosen to limit the controlling expressions of while-true and do-while-false loop idioms to Boolean constants. This is because the Exceptions on the MISRA C document allow any dowhile (evaluating either to a true value for Exception 1 and a false value for Exception 2);

  • other loop idioms can be added using the -loop_idioms global configuration;

  • in addition, reports for any statements with controlling expressions that have fixed values can be tagged using the statements service configuration.

Implementation

The rule only reports an expression if it can be detected that the expression will always have the same value.

Imprecision

False negatives are present because, in general, the fixed values of constant expressions may not be statically known.

Configuration

See generic service options.

Option statements
statements
-config=MC4.R14.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R14.4

Aliases

MC3.R14.4, MC3R2.R14.4, MC3A4.R14.4, MC3A3.R14.4, MC3C2.R14.4, MC3A2.R14.4, MC3R1.R14.4, MC3C1.R14.4, MC3A1.R14.4, MC3R0.R14.4

Summary

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type. (See page 129 of MISRA-C-2012 [45] , page 131 of MISRA-C-2012-Revision-1 [51] , page 152 of MISRA-C-2023 [58] , page 152 of MISRA-C-2025 [59] .)

Description

Notes:

  • See page 283 of MISRA C:2023 [58] , Appendix D for the type category essentially Boolean.

  • do statements expanded from a macro-defined do-while-zero loop idiom are ignored.

  • Reports about essential types can be tagged using the etypes service configuration.

For example, with the code:

void foo(unsigned y) {
  if (y) { /*... */ }
}

The service will report as a violation the reference to y in the if statement condition. However, with the following configuration line the report will be deviated:

-doc="Using an unsigned integer value as controlling expression is allowed."
-config=MC4.R14.4,etypes+={safe, "any()", "src_type(unsigned)"},

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R14.4,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R15.1

Aliases

MC3.R15.1, MC3R2.R15.1, MC3A4.R15.1, MC3A3.R15.1, MC3C2.R15.1, MC3A2.R15.1, MC3R1.R15.1, MC3C1.R15.1, MC3A1.R15.1, MC3R0.R15.1

Summary

The goto statement should not be used. (See page 130 of MISRA-C-2012 [45] , page 132 of MISRA-C-2012-Revision-1 [51] , page 153 of MISRA-C-2023 [58] , page 153 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R15.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R15.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R15.2

Aliases

MC3.R15.2, MC3R2.R15.2, MC3A4.R15.2, MC3A3.R15.2, MC3C2.R15.2, MC3A2.R15.2, MC3R1.R15.2, MC3C1.R15.2, MC3A1.R15.2, MC3R0.R15.2

Summary

The goto statement shall jump to a label declared later in the same function. (See page 130 of MISRA-C-2012 [45] , page 132 of MISRA-C-2012-Revision-1 [51] , page 153 of MISRA-C-2023 [58] , page 153 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R15.3

Aliases

MC3.R15.3, MC3R2.R15.3, MC3A4.R15.3, MC3A3.R15.3, MC3C2.R15.3, MC3A2.R15.3, MC3R1.R15.3, MC3C1.R15.3, MC3A1.R15.3, MC3R0.R15.3

Summary

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement. (See page 131 of MISRA-C-2012 [45] , page 133 of MISRA-C-2012-Revision-1 [51] , page 22 of MISRA-C-2012-Amendment-2 [52] , page 154 of MISRA-C-2023 [58] , page 154 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R15.4

Aliases

MC3.R15.4, MC3R2.R15.4, MC3A4.R15.4, MC3A3.R15.4, MC3C2.R15.4, MC3A2.R15.4, MC3R1.R15.4, MC3C1.R15.4, MC3A1.R15.4, MC3R0.R15.4

Summary

There should be no more than one break or goto statement used to terminate any iteration statement. (See page 133 of MISRA-C-2012 [45] , page 135 of MISRA-C-2012-Revision-1 [51] , page 155 of MISRA-C-2023 [58] , page 155 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC3.R15.5

Aliases

MC3R2.R15.5, MC3A4.R15.5, MC3A3.R15.5, MC3C2.R15.5, MC3A2.R15.5, MC3R1.R15.5, MC3C1.R15.5, MC3A1.R15.5, MC3R0.R15.5

Summary

A function should have a single point of exit at the end. (See page 134 of MISRA-C-2012 [45] , page 136 of MISRA-C-2012-Revision-1 [51] , page 157 of MISRA-C-2023 [58] , page 157 of MISRA-C-2025 [59] .)

Description

It is reported if a function does not have a single point of exit at the end of the function block. Notes:

  • what constitutes a function exit node can be specified by means of the exit_kind service configuration;

  • what constitutes an end position of a function can be specified by mean of the end_position service configuration.

For example, with the configure lines:

-doc_begin="Return statements and calls to noreturn functions may only occur at the end
or at the end of a try block or catch handler."
-config=MC3.R15.5,!exit_kind={return, only_at_end_position, true},
{noreturn_call, only_at_end_position, true}
-config=MC3.R15.5,end_position+={{compound_try, compound_catch}, true}
-doc_end

the return statements and calls to functions with the noreturn property are considered to be function exits and these exits may only occur at the end of the function body or at the end of a try block or catch handler when last statement of the function body is the handled try block.

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=MC3.R15.5,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=MC3.R15.5,exit_kind={return, only_at_end_position, true},
  {noreturn_call, anywhere, true}

Option end_position
end_position
-config=MC3.R15.5,end_position={{POS,...}, END},...

Specify the end positions and if an exit node is required.

The configuration’s content is a list of the end positions and if a exit kind node is required at that position.

{POS,…}:

end position in the function body. Accepted members are:

  • compound: the end of the body when the body is a compound statement;

  • try: the end of the body when the body is a try block;

  • catch: the end of a catch handler when the body is a try block;

  • compound_try: the end of a try block when last statement of the function body is the try block;

  • compound_catch: the end of a catch handler when last statement of the function body is the handled try block;

END:

whether the exit position must always have an exit kind node. Accepted values are:

  • true: the exit position must always have an exit node;

  • false: the exit position does not have to have an exit node;

Default:

-config=MC3.R15.5,end_position={{compound, try}, false}

Rule MC4.R15.5

Aliases

Summary

A function should have a single point of exit at the end. (See page 157 of MISRA-C-2025 [59] .)

Description

It is reported if a function does not have a single point of exit at the end of the function block. Notes:

  • what constitutes a function exit node can be specified by means of the exit_kind service configuration;

  • what constitutes an end position of a function can be specified by mean of the end_position service configuration.

For example, with the configure lines:

-doc_begin="Return statements and calls to noreturn functions may only occur at the end
or at the end of a try block or catch handler."
-config=MC4.R15.5,!exit_kind={return, only_at_end_position, true},
{noreturn_call, only_at_end_position, true}
-config=MC4.R15.5,end_position+={{compound_try, compound_catch}, true}
-doc_end

the return statements and calls to functions with the noreturn property are considered to be function exits and these exits may only occur at the end of the function body or at the end of a try block or catch handler when last statement of the function body is the handled try block.

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=MC4.R15.5,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=MC4.R15.5,exit_kind={return, only_at_end_position, true},
  {noreturn_call, anywhere, true}

Option end_position
end_position
-config=MC4.R15.5,end_position={{POS,...}, END},...

Specify the end positions and if an exit node is required.

The configuration’s content is a list of the end positions and if a exit kind node is required at that position.

{POS,…}:

end position in the function body. Accepted members are:

  • compound: the end of the body when the body is a compound statement;

  • try: the end of the body when the body is a try block;

  • catch: the end of a catch handler when the body is a try block;

  • compound_try: the end of a try block when last statement of the function body is the try block;

  • compound_catch: the end of a catch handler when last statement of the function body is the handled try block;

END:

whether the exit position must always have an exit kind node. Accepted values are:

  • true: the exit position must always have an exit node;

  • false: the exit position does not have to have an exit node;

Default:

-config=MC4.R15.5,end_position={{compound, try}, false}

Rule MC4.R15.6

Aliases

MC3.R15.6, MC3R2.R15.6, MC3A4.R15.6, MC3A3.R15.6, MC3C2.R15.6, MC3A2.R15.6, MC3R1.R15.6, MC3C1.R15.6, MC3A1.R15.6, MC3R0.R15.6

Summary

The body of an iteration-statement or a selection-statement shall be a compound-statement. (See page 135 of MISRA-C-2012 [45] , page 137 of MISRA-C-2012-Revision-1 [51] , page 15 of MISRA-C-2012-TC1 [48] , page 158 of MISRA-C-2023 [58] , page 158 of MISRA-C-2025 [59] .)

Description

More specifically, the rule reports:

  • any switch, do, for, or while statement that does not have its body enclosed in braces;

  • any if statement that does not have the condition part immediately followed by a compound statement;

  • any else keyword that is not followed by another if statement or by a compound statement.

Configuration

See generic service options.

Rule MC4.R15.7

Aliases

MC3.R15.7, MC3R2.R15.7, MC3A4.R15.7, MC3A3.R15.7, MC3C2.R15.7, MC3A2.R15.7, MC3R1.R15.7, MC3C1.R15.7, MC3A1.R15.7, MC3R0.R15.7

Summary

All if ... else if constructs shall be terminated with an else statement. (See page 137 of MISRA-C-2012 [45] , page 139 of MISRA-C-2012-Revision-1 [51] , page 15 of MISRA-C-2012-TC1 [48] , page 16 of MISRA-C-2012-TC2 [54] , page 160 of MISRA-C-2023 [58] , page 160 of MISRA-C-2025 [59] , page 24 of MISRA-C-2012-Permits-1 [53] .)

Description

Reports any if statement if the final else if:

  • has no else clause and no matching comment as to why it is missing,

  • has an else clause that is the null statement and no matching comment as to why it is null, or

  • has an else clause that is a compound statement that has no effect and there is no matching explanatory comment.

The default configuration does not check the content or style of the comment; however the else_empty service configuration can be used to provide a comment matcher.

Configuration

See generic service options.

Option else_empty
else_empty
-config=MC4.R15.7,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC4.R15.7,else_empty={missing, "none()"}, {no_effect, "any()"}

Option ignored_comments
ignored_comments
-config=MC4.R15.7,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R16.1

Aliases

MC3.R16.1, MC3R2.R16.1, MC3A4.R16.1, MC3A3.R16.1, MC3C2.R16.1, MC3A2.R16.1, MC3R1.R16.1, MC3C1.R16.1, MC3A1.R16.1, MC3R0.R16.1

Summary

All switch statements shall be well-formed. (See page 138 of MISRA-C-2012 [45] , page 140 of MISRA-C-2012-Revision-1 [51] , page 15 of MISRA-C-2012-TC1 [48] , page 22 of MISRA-C-2012-Amendment-2 [52] , page 161 of MISRA-C-2023 [58] , page 161 of MISRA-C-2025 [59] , page 25 of MISRA-C-2012-Permits-1 [53] .)

Description

It is reported if the switch-clauses are not terminated with a break statement. For terminating statements other than break, the reports can be tagged by means of the terminals service configuration.

For example, with the configure line:

-doc="Terminals statements with a noreturn function are safe."
-config=MC4.R16.1,terminals={safe,"call(property(noreturn))"}

if the last statement of the switch-clause is a call to a function with the noreturn property, then the report will have the tag safe.

Configuration

See generic service options.

Option terminals
terminals
-config=MC4.R16.1,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MC4.R16.1,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC4.R16.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R16.2

Aliases

MC3.R16.2, MC3R2.R16.2, MC3A4.R16.2, MC3A3.R16.2, MC3C2.R16.2, MC3A2.R16.2, MC3R1.R16.2, MC3C1.R16.2, MC3A1.R16.2, MC3R0.R16.2

Summary

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement. (See page 139 of MISRA-C-2012 [45] , page 141 of MISRA-C-2012-Revision-1 [51] , page 162 of MISRA-C-2023 [58] , page 162 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option switch_clauses
switch_clauses
-config=MC4.R16.2,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC4.R16.2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R16.3

Aliases

MC3.R16.3, MC3R2.R16.3, MC3A4.R16.3, MC3A3.R16.3, MC3C2.R16.3, MC3A2.R16.3, MC3R1.R16.3, MC3C1.R16.3, MC3A1.R16.3, MC3R0.R16.3

Summary

An unconditional break statement shall terminate every * switch-clause*. (See page 139 of MISRA-C-2012 [45] , page 141 of MISRA-C-2012-Revision-1 [51] , page 163 of MISRA-C-2023 [58] , page 163 of MISRA-C-2025 [59] , page 25 of MISRA-C-2012-Permits-1 [53] .)

Description

It is reported if the switch-clause are not terminated with a break statement. For terminating statements other than break, the reports can be tagged by means of the terminals service configuration.

For example, with the configure line:

-doc="Terminals statements with a noreturn function are safe."
-config=MC4.R16.3,terminals={safe,"call(property(noreturn))"}

if the last statement of the switch-clause is a call to a function with the noreturn property, then the report will have the tag safe.

Configuration

See generic service options.

Option terminals
terminals
-config=MC4.R16.3,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MC4.R16.3,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC4.R16.3,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R16.4

Aliases

MC3.R16.4, MC3R2.R16.4, MC3A4.R16.4, MC3A3.R16.4, MC3C2.R16.4, MC3A2.R16.4, MC3R1.R16.4, MC3C1.R16.4, MC3A1.R16.4, MC3R0.R16.4

Summary

Every switch statement shall have a default label. (See page 140 of MISRA-C-2012 [45] , page 142 of MISRA-C-2012-Revision-1 [51] , page 164 of MISRA-C-2023 [58] , page 164 of MISRA-C-2025 [59] , page 26 of MISRA-C-2012-Permits-1 [53] .)

Description

It is reported if the default label is followed by a break statement without any interleaving non-empty statement or comment

Configuration

See generic service options.

Option terminals
terminals
-config=MC4.R16.4,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MC4.R16.4,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC4.R16.4,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R16.5

Aliases

MC3.R16.5, MC3R2.R16.5, MC3A4.R16.5, MC3A3.R16.5, MC3C2.R16.5, MC3A2.R16.5, MC3R1.R16.5, MC3C1.R16.5, MC3A1.R16.5, MC3R0.R16.5

Summary

A default label shall appear as either the first or the last switch label of a switch statement. (See page 142 of MISRA-C-2012 [45] , page 144 of MISRA-C-2012-Revision-1 [51] , page 165 of MISRA-C-2023 [58] , page 165 of MISRA-C-2025 [59] , page 26 of MISRA-C-2012-Permits-1 [53] .)

Configuration

See generic service options.

Option switch_clauses
switch_clauses
-config=MC4.R16.5,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC4.R16.5,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R16.6

Aliases

MC3.R16.6, MC3R2.R16.6, MC3A4.R16.6, MC3A3.R16.6, MC3C2.R16.6, MC3A2.R16.6, MC3R1.R16.6, MC3C1.R16.6, MC3A1.R16.6, MC3R0.R16.6

Summary

Every switch statement shall have at least two switch-clauses. (See page 143 of MISRA-C-2012 [45] , page 145 of MISRA-C-2012-Revision-1 [51] , page 166 of MISRA-C-2023 [58] , page 166 of MISRA-C-2025 [59] , page 27 of MISRA-C-2012-Permits-1 [53] .)

Description

It is reported if a switch statement has a single switch-clause. To allow a single switch-clause and no default label, use the switch_clauses service configuration.

For example, with the configuration lines:

-doc="A switch statement with a single switch-clause and no default label
can be used to improve readability."
-config=MC4.R16.6,switch_clause={deliberate, "default(0)"}

the reports of switch statements with a single switch-clause and no default label will have the tag deliberate.

Configuration

See generic service options.

Option switch_clauses
switch_clauses
-config=MC4.R16.6,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC4.R16.6,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC4.R16.7

Aliases

MC3.R16.7, MC3R2.R16.7, MC3A4.R16.7, MC3A3.R16.7, MC3C2.R16.7, MC3A2.R16.7, MC3R1.R16.7, MC3C1.R16.7, MC3A1.R16.7, MC3R0.R16.7

Summary

A switch-expression shall not have essentially Boolean type. (See page 144 of MISRA-C-2012 [45] , page 146 of MISRA-C-2012-Revision-1 [51] , page 167 of MISRA-C-2023 [58] , page 167 of MISRA-C-2025 [59] , page 27 of MISRA-C-2012-Permits-1 [53] .)

Description

See page 283 of MISRA C:2023 [58] , Appendix D for the type category essentially Boolean.

Note that reports about essential types can be tagged using the etypes service configuration.

Configuration

See generic service options.

Option etypes
etypes
-config=MC4.R16.7,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC4.R17.1

Aliases

MC3.R17.1, MC3R2.R17.1, MC3A4.R17.1, MC3A3.R17.1, MC3C2.R17.1, MC3A2.R17.1, MC3R1.R17.1, MC3C1.R17.1, MC3A1.R17.1, MC3R0.R17.1

Summary

The features of <stdarg.h> shall not be used. (See page 144 of MISRA-C-2012 [45] , page 146 of MISRA-C-2012-Revision-1 [51] , page 22 of MISRA-C-2012-Amendment-2 [52] , page 167 of MISRA-C-2023 [58] , page 167 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R17.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC4.R17.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R17.2

Aliases

MC3.R17.2, MC3R2.R17.2, MC3A4.R17.2, MC3A3.R17.2, MC3C2.R17.2, MC3A2.R17.2, MC3R1.R17.2, MC3C1.R17.2, MC3A1.R17.2, MC3R0.R17.2

Summary

Functions shall not call themselves, either directly or indirectly. (See page 145 of MISRA-C-2012 [45] , page 147 of MISRA-C-2012-Revision-1 [51] , page 168 of MISRA-C-2023 [58] , page 168 of MISRA-C-2025 [59] .)

Description

For any function that is non-compliant, the report will show all calls in the chain that lead to it calling itself.

Imprecision

Cautions are reported when the recursion relies on indirect function calls to form the chain.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R17.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=MC4.R17.2,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule MC4.R17.3

Aliases

MC3.R17.3, MC3R2.R17.3, MC3A4.R17.3, MC3A3.R17.3, MC3C2.R17.3, MC3A2.R17.3, MC3R1.R17.3, MC3C1.R17.3, MC3A1.R17.3, MC3R0.R17.3

Summary

A function shall not be declared implicitly. (See page 146 of MISRA-C-2012 [45] , page 148 of MISRA-C-2012-Revision-1 [51] , page 168 of MISRA-C-2023 [58] , page 168 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R17.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R17.3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R17.4

Aliases

MC3.R17.4, MC3R2.R17.4, MC3A4.R17.4, MC3A3.R17.4, MC3C2.R17.4, MC3A2.R17.4, MC3R1.R17.4, MC3C1.R17.4, MC3A1.R17.4, MC3R0.R17.4

Summary

All exit paths from a function with non-void return type shall have an explicit return statement with an expression. (See page 146 of MISRA-C-2012 [45] , page 148 of MISRA-C-2012-Revision-1 [51] , page 22 of MISRA-C-2012-Amendment-2 [52] , page 17 of MISRA-C-2012-TC2 [54] , page 169 of MISRA-C-2023 [58] , page 169 of MISRA-C-2025 [59] .)

Exceptions

Note that for all standards except for C90 and C95, the main function is exempt from this rule and the return statement can be omitted

Configuration

See generic service options.

Option statements
statements
-config=MC4.R17.4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R17.4,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=MC4.R17.4,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MC3A2.R17.5

Aliases

MC3R1.R17.5, MC3C1.R17.5, MC3A1.R17.5, MC3R0.R17.5

Summary

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements. (See page 147 of MISRA-C-2012 [45] , page 149 of MISRA-C-2012-Revision-1 [51] .)

Imprecision

Cautions are reported when the call argument type is a pointer.

Configuration

See generic service options.

Option calls
calls
-config=MC3A2.R17.5,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MC4.R17.5

Aliases

MC3.R17.5, MC3R2.R17.5, MC3A4.R17.5, MC3A3.R17.5, MC3C2.R17.5

Summary

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements. (See page 17 of MISRA-C-2012-TC2 [54] , page 170 of MISRA-C-2023 [58] , page 170 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported when the call argument type is a pointer.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R17.5,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MC3.R17.6

Aliases

MC3R2.R17.6, MC3A4.R17.6, MC3A3.R17.6, MC3C2.R17.6, MC3A2.R17.6, MC3R1.R17.6, MC3C1.R17.6, MC3A1.R17.6, MC3R0.R17.6

Summary

The declaration of an array parameter shall not contain the static keyword between the [ ]. (See page 148 of MISRA-C-2012 [45] , page 150 of MISRA-C-2012-Revision-1 [51] , page 22 of MISRA-C-2012-Amendment-2 [52] , page 171 of MISRA-C-2023 [58] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC3.R17.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R17.7

Aliases

MC3.R17.7, MC3R2.R17.7, MC3A4.R17.7, MC3A3.R17.7, MC3C2.R17.7, MC3A2.R17.7, MC3R1.R17.7, MC3C1.R17.7, MC3A1.R17.7, MC3R0.R17.7

Summary

The value returned by a function having non-void return type shall be * used*. (See page 149 of MISRA-C-2012 [45] , page 151 of MISRA-C-2012-Revision-1 [51] , page 172 of MISRA-C-2023 [58] , page 172 of MISRA-C-2025 [59] .)

Description

Notes:

  • calls to a non-void function whose return value is ignored are reported;

  • calls where the return value is cast to void are not individually reported as the explicit cast to void is taken to be a deviation request by the user.

  • all calls are included in a statistical summary for the program and the called function;

  • the summary provides:

    • the number of calls to the function,

    • the number of times the return value is ignored but this was expected,

    • the number of times the return value is cast to void and

    • the number of times it is ignored unexpectedly;

  • the selection of samples to be shown can be changed using the sample_reports service configuration.

  • the number of samples shown can be changed using the use_samples service configuration.

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=MC4.R17.7,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option use_samples
use_samples
-config=MC4.R17.7,use_samples={TAG, MAX},...

Specify the maximum number of samples to be output.

The configuration’s content is a list of return use tags (ignored, to_void, used) with the maximum number of samples to be output; if a use tag is not specified, then all calls matching the tag will be shown as violations.

TAG:

tag indicating the return use. Accepted values are:

  • used: return value is used;

  • ignored: return value is ignored;

  • to_void: return value is cast to void;

MAX:

maximum number of samples to be shown. It must be an integer greater than or equal to -1.

Default:

-config=MC4.R17.7,use_samples={ignored, -1}, {to_void, 1}, {used, 1}

Option calls
calls
-config=MC4.R17.7,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=MC4.R17.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R17.8

Aliases

MC3.R17.8, MC3R2.R17.8, MC3A4.R17.8, MC3A3.R17.8, MC3C2.R17.8, MC3A2.R17.8, MC3R1.R17.8, MC3C1.R17.8, MC3A1.R17.8, MC3R0.R17.8

Summary

A function parameter should not be modified. (See page 150 of MISRA-C-2012 [45] , page 152 of MISRA-C-2012-Revision-1 [51] , page 173 of MISRA-C-2023 [58] , page 173 of MISRA-C-2025 [59] .)

Description

Notes:

  • Once the address of a parameter is assigned to a const pointer further assignments by the assignee are not checked to see if the const is removed.

For example, the use of the parameter a in:

void f(int a) {
const int *p = &a;
int *q = (int *)p;
*q = 2;
}

is considered to be compliant and a is not reported. Note that the cast (int *)p that removes the const qualifier is reported by Service MC.R11.8.

  • Assigning the address of a pointer parameter to a non-const pointer is reported as a violation.

For example, in:

void l(int a) {
int *p = &a;
}

if there is no intent to modify the pointee, p should be declared as a const pointer. Note that, since the pointee is not modified, the declaration for p is also reported by Service MC.R8.13.

Configuration

See generic service options.

Rule MC4.R17.9

Aliases

MC3.R17.9, MC3R2.R17.9, MC3A4.R17.9, MC3A3.R17.9

Summary

A function declared with a _Noreturn function specifier shall not return to its caller. (See page 25 of MISRA-C-2012-Amendment-3 [55] , page 174 of MISRA-C-2023 [58] , page 174 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R17.9,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R17.9,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=MC4.R17.9,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MC4.R17.10

Aliases

MC3.R17.10, MC3R2.R17.10, MC3A4.R17.10, MC3A3.R17.10

Summary

A function declared with a _Noreturn function specifier shall have * void* return type. (See page 26 of MISRA-C-2012-Amendment-3 [55] , page 175 of MISRA-C-2023 [58] , page 175 of MISRA-C-2025 [59] .)

Description

Constructor and destructor declarations and definitions are also reported as violations, although their implicit return type is void. The rationale for this extension to the rule is that there is no reason for these methods to have the [[noreturn]] attribute.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R17.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R17.11

Aliases

MC3.R17.11, MC3R2.R17.11, MC3A4.R17.11, MC3A3.R17.11

Summary

A function that never returns should be declared with a _Noreturn function specifier. (See page 27 of MISRA-C-2012-Amendment-3 [55] , page 175 of MISRA-C-2023 [58] , page 175 of MISRA-C-2025 [59] .)

Description

The following guidelines are recommended in dealing with violations of this rule:

  • when using the [40] or later, add the _Noreturn function specifier

  • when using the [39] or later, use the [[noreturn]] function specifier

  • otherwise, use the -call_properties global configuration as shown below:

-call_properties={"REGEX",{noreturn}}
  • alternatively, if your compiler supports it, the __attribute__((noreturn)) specifier can be used instead

Imprecision

False negatives can occur when the analyzer cannot guarantee the code will never reach any return point of a function.

Configuration

See generic service options.

Rule MC4.R17.12

Aliases

MC3.R17.12, MC3R2.R17.12, MC3A4.R17.12, MC3A3.R17.12

Summary

A function identifier should only be used with either a preceding &, or with a parenthesized parameter list. (See page 27 of MISRA-C-2012-Amendment-3 [55] , page 176 of MISRA-C-2023 [58] , page 176 of MISRA-C-2025 [59] .)

Description

Note that the rule uses the semantic interpretation with respect to the phrase preceded by, as described in MISRA forum thread “Rule 16.9”.

Configuration

See generic service options.

Option statements
statements
-config=MC4.R17.12,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R17.12,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R17.13

Aliases

MC3.R17.13, MC3R2.R17.13, MC3A4.R17.13, MC3A3.R17.13

Summary

A function type shall not be type qualified. (See page 28 of MISRA-C-2012-Amendment-3 [55] , page 176 of MISRA-C-2023 [58] , page 176 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=MC4.R17.13,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MC4.R18.1

Aliases

MC3.R18.1, MC3R2.R18.1, MC3A4.R18.1, MC3A3.R18.1, MC3C2.R18.1, MC3A2.R18.1, MC3R1.R18.1, MC3C1.R18.1, MC3A1.R18.1, MC3R0.R18.1

Summary

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand. (See page 151 of MISRA-C-2012 [45] , page 153 of MISRA-C-2012-Revision-1 [51] , page 23 of MISRA-C-2012-Amendment-2 [52] , page 17 of MISRA-C-2012-TC2 [54] , page 177 of MISRA-C-2023 [58] , page 177 of MISRA-C-2025 [59] , page 27 of MISRA-C-2012-Permits-1 [53] .)

Imprecision

Cautions are reported for every suspect case found.

False negatives are present when the checker precision is insufficient.

Configuration

See generic service options.

Rule MC4.R18.2

Aliases

MC3.R18.2, MC3R2.R18.2, MC3A4.R18.2, MC3A3.R18.2, MC3C2.R18.2, MC3A2.R18.2, MC3R1.R18.2, MC3C1.R18.2, MC3A1.R18.2, MC3R0.R18.2

Summary

Subtraction between pointers shall only be applied to pointers that address elements of the same array. (See page 153 of MISRA-C-2012 [45] , page 155 of MISRA-C-2012-Revision-1 [51] , page 180 of MISRA-C-2023 [58] , page 180 of MISRA-C-2025 [59] .)

Description

Note that, for this rule, there is no requirement that the pointers have array types

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported. For example, with the configuration line:

-decl_properties+={"^(data_end|data_start)$", {"alloc_id(alloc_data)"}}
extern char data_start[];
extern const char data_end[];

int main() {
char * p = data_end - data_start;
}

the subtraction data_end-data_start is not reported.

Imprecision

Cautions are reported when the analyzer is uncertain whether the pointers point to the same array.

Configuration

See generic service options.

Rule MC3A3.R18.3

Aliases

MC3C2.R18.3, MC3A2.R18.3, MC3R1.R18.3, MC3C1.R18.3, MC3A1.R18.3, MC3R0.R18.3

Summary

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object. (See page 154 of MISRA-C-2012 [45] , page 156 of MISRA-C-2012-Revision-1 [51] .)

Description

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported.

Imprecision

Cautions are reported when the analyzer is uncertain whether the pointers point to the same object.

Configuration

See generic service options.

Rule MC4.R18.3

Aliases

MC3.R18.3, MC3R2.R18.3, MC3A4.R18.3

Summary

The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object. (See page 41 of MISRA-C-2012-Amendment-4 [57] , page 181 of MISRA-C-2023 [58] , page 181 of MISRA-C-2025 [59] .)

Description

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported.

Imprecision

Cautions are reported when the analyzer is uncertain whether the pointers point to the same object.

Configuration

See generic service options.

Rule MC4.R18.4

Aliases

MC3.R18.4, MC3R2.R18.4, MC3A4.R18.4, MC3A3.R18.4, MC3C2.R18.4, MC3A2.R18.4, MC3R1.R18.4, MC3C1.R18.4, MC3A1.R18.4, MC3R0.R18.4

Summary

The +, -, += and -= operators should not be applied to an expression of pointer type. (See page 155 of MISRA-C-2012 [45] , page 157 of MISRA-C-2012-Revision-1 [51] , page 182 of MISRA-C-2023 [58] , page 182 of MISRA-C-2025 [59] .)

Imprecision

Cautions for array subscript expressions are reported when it cannot be determined whether the expression refers to an array.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R18.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R18.5

Aliases

MC3.R18.5, MC3R2.R18.5, MC3A4.R18.5, MC3A3.R18.5, MC3C2.R18.5, MC3A2.R18.5, MC3R1.R18.5, MC3C1.R18.5, MC3A1.R18.5, MC3R0.R18.5

Summary

Declarations should contain no more than two levels of pointer nesting. (See page 156 of MISRA-C-2012 [45] , page 158 of MISRA-C-2012-Revision-1 [51] , page 183 of MISRA-C-2023 [58] , page 183 of MISRA-C-2025 [59] .)

Description

It is reported if there are more than two levels of pointer indirection for:

  • the type of a typedef declaration,

  • the declared type of an object,

  • the return type of a function.

Configuration

See generic service options.

Rule MC3A3.R18.6

Aliases

MC3C2.R18.6, MC3A2.R18.6, MC3R1.R18.6, MC3C1.R18.6, MC3A1.R18.6, MC3R0.R18.6

Summary

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist. (See page 158 of MISRA-C-2012 [45] , page 160 of MISRA-C-2012-Revision-1 [51] .)

Imprecision

Cautions are reported when the address is possibly passed in a function call to another automatic object of larger scope or a static object.

Configuration

See generic service options.

Rule MC4.R18.6

Aliases

MC3.R18.6, MC3R2.R18.6, MC3A4.R18.6

Summary

The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist. (See page 22 of MISRA-C-2012-Amendment-4 [57] , page 184 of MISRA-C-2023 [58] , page 184 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported when the address is possibly passed in a function call to another automatic object of larger scope or a static object.

Configuration

See generic service options.

Rule MC4.R18.7

Aliases

MC3.R18.7, MC3R2.R18.7, MC3A4.R18.7, MC3A3.R18.7, MC3C2.R18.7, MC3A2.R18.7, MC3R1.R18.7, MC3C1.R18.7, MC3A1.R18.7, MC3R0.R18.7

Summary

Flexible array members shall not be declared. (See page 159 of MISRA-C-2012 [45] , page 161 of MISRA-C-2012-Revision-1 [51] , page 185 of MISRA-C-2023 [58] , page 185 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R18.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3A3.R18.8

Aliases

MC3C2.R18.8, MC3A2.R18.8, MC3R1.R18.8, MC3C1.R18.8, MC3A1.R18.8, MC3R0.R18.8

Summary

Variable-length array types shall not be used. (See page 160 of MISRA-C-2012 [45] , page 162 of MISRA-C-2012-Revision-1 [51] .)

Configuration

See generic service options.

Option types
types
-config=MC3A3.R18.8,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MC3A3.R18.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R18.8

Aliases

MC3.R18.8, MC3R2.R18.8, MC3A4.R18.8

Summary

Variable-length arrays shall not be used. (See page 23 of MISRA-C-2012-Amendment-4 [57] , page 186 of MISRA-C-2023 [58] , page 186 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option types
types
-config=MC4.R18.8,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MC4.R18.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R18.9

Aliases

MC3.R18.9, MC3R2.R18.9, MC3A4.R18.9, MC3A3.R18.9

Summary

An object with temporary lifetime shall not undergo array-to-pointer conversion. (See page 29 of MISRA-C-2012-Amendment-3 [55] , page 187 of MISRA-C-2023 [58] , page 187 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R18.10

Aliases

MC3.R18.10, MC3R2.R18.10, MC3A4.R18.10

Summary

Pointers to variably-modified array types shall not be used. (See page 24 of MISRA-C-2012-Amendment-4 [57] , page 189 of MISRA-C-2023 [58] , page 189 of MISRA-C-2025 [59] .)

Description

Only variably-modified types (see paragraph 3, Section 6.7.6, [40]) are reported by this service. Other variable-length array types are shown by MC.R18.10.

Configuration

See generic service options.

Option types
types
-config=MC4.R18.10,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MC4.R18.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R19.1

Aliases

MC3.R19.1, MC3R2.R19.1, MC3A4.R19.1, MC3A3.R19.1, MC3C2.R19.1, MC3A2.R19.1, MC3R1.R19.1, MC3C1.R19.1, MC3A1.R19.1, MC3R0.R19.1

Summary

An object shall not be assigned or copied to an overlapping object. (See page 161 of MISRA-C-2012 [45] , page 163 of MISRA-C-2012-Revision-1 [51] , page 16 of MISRA-C-2012-TC1 [48] , page 190 of MISRA-C-2023 [58] , page 190 of MISRA-C-2025 [59] .)

Description

It is reported if:

  • a library function other than memmove for copying objects is used to copy (possibly) overlapping objects;

  • a member of a union is copied to another member (or subexpression of another member) of the same union that points to the same allocation area and has incompatible type; or

  • a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union.

An exception to the last item is when a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union, both members are arrays and the sub-expressions are array elements with the same type and they are at the same constant offset.

Imprecision

Cautions are reported when the analyzer is uncertain whether the objects overlap.

False positives are reported because the rule needs a deeper (much more expensive) semantic analysis.

False negatives are present because the rule needs a deeper (much more expensive) semantic analysis.

Configuration

See generic service options.

Rule MC4.R19.2

Aliases

MC3.R19.2, MC3R2.R19.2, MC3A4.R19.2, MC3A3.R19.2, MC3C2.R19.2, MC3A2.R19.2, MC3R1.R19.2, MC3C1.R19.2, MC3A1.R19.2, MC3R0.R19.2

Summary

The union keyword should not be used. (See page 162 of MISRA-C-2012 [45] , page 164 of MISRA-C-2012-Revision-1 [51] , page 191 of MISRA-C-2023 [58] , page 191 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R19.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC4.R19.2,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC4.R19.3

Aliases

Summary

A union member shall not be read unless it has been previously set. (See page 191 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported on any access to a union member

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R19.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R20.1

Aliases

MC3.R20.1, MC3R2.R20.1, MC3A4.R20.1, MC3A3.R20.1, MC3C2.R20.1, MC3A2.R20.1, MC3R1.R20.1, MC3C1.R20.1, MC3A1.R20.1, MC3R0.R20.1

Summary

#include directives should only be preceded by preprocessor directives or comments. (See page 163 of MISRA-C-2012 [45] , page 165 of MISRA-C-2012-Revision-1 [51] , page 192 of MISRA-C-2023 [58] , page 192 of MISRA-C-2025 [59] .)

Description

Note that the headers service configuration can be used to attach a report tag to matching #include files. For example:

-doc='The header file "header.h" has been designed to be included in specific areas not always compatible with the guideline.'
-config=MC4.R20.1,headers+={safe, "^<header\\.h>$"}

attaches the tag safe to a report concerning the directive #include "header.h".

Exceptions

The exception service configuration allows for some exceptions to the rule.

Configuration

See generic service options.

Option headers
headers
-config=MC4.R20.1,headers={TAGS, HEADER_MATCHER},...

Specifies report tags for the #include directives.

The configuration’s content is a list of clauses specifying report tags for matching #include names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

HEADER_MATCHER:

the #include argument matcher including quotes or chevrons. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option exception
exception
-config=MC4.R20.1,exception=EXCEPT,...

Specify allowed exceptions to this rule.

{EXCEPT,…}:

allowed exception to this rule. Accepted members are:

  • extern_C: constructs of the form extern "C" {...} are not considered to be code (for ‘C++’ rules);

  • extern_C_only: constructs of the form extern "C" are not considered to be code (for ‘C++’ rules); the following {…} may only contain preprocessor directives;

  • namespace_alias: constructs of the form namespace A = B are not considered to be code;

  • if_directive: directive subsections that are bounded by the #if, #else, #elif and #endif directives are considered as separate code chunks;


Rule MC4.R20.2

Aliases

MC3.R20.2, MC3R2.R20.2, MC3A4.R20.2, MC3A3.R20.2, MC3C2.R20.2, MC3A2.R20.2, MC3R1.R20.2, MC3C1.R20.2, MC3A1.R20.2, MC3R0.R20.2

Summary

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name. (See page 164 of MISRA-C-2012 [45] , page 166 of MISRA-C-2012-Revision-1 [51] , page 193 of MISRA-C-2023 [58] , page 193 of MISRA-C-2025 [59] .)

Description

To avoid the reporting of \ in file path names, the path_uses_backslash service configuration should be used.

The reports can be tagged using the include_name_exception.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MC4.R20.2,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MC4.R20.2,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MC4.R20.3

Aliases

MC3.R20.3, MC3R2.R20.3, MC3A4.R20.3, MC3A3.R20.3, MC3C2.R20.3, MC3A2.R20.3, MC3R1.R20.3, MC3C1.R20.3, MC3A1.R20.3, MC3R0.R20.3

Summary

The #include directive shall be followed by either a <filename> or "filename" sequence. (See page 164 of MISRA-C-2012 [45] , page 166 of MISRA-C-2012-Revision-1 [51] , page 193 of MISRA-C-2023 [58] , page 193 of MISRA-C-2025 [59] .)

Description

The reports can be tagged using the include_name_exception.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MC4.R20.3,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MC4.R20.3,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MC4.R20.4

Aliases

MC3.R20.4, MC3R2.R20.4, MC3A4.R20.4, MC3A3.R20.4, MC3C2.R20.4, MC3A2.R20.4, MC3R1.R20.4, MC3C1.R20.4, MC3A1.R20.4, MC3R0.R20.4

Summary

A macro shall not be defined with the same name as a keyword. (See page 165 of MISRA-C-2012 [45] , page 167 of MISRA-C-2012-Revision-1 [51] , page 23 of MISRA-C-2012-Amendment-2 [52] , page 194 of MISRA-C-2023 [58] , page 194 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC4.R20.4,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC4.R20.4,reserved_standard="std()"

Option macros
macros
-config=MC4.R20.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=MC4.R20.4,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R20.5

Aliases

MC3.R20.5, MC3R2.R20.5, MC3A4.R20.5, MC3A3.R20.5, MC3C2.R20.5, MC3A2.R20.5, MC3R1.R20.5, MC3C1.R20.5, MC3A1.R20.5, MC3R0.R20.5

Summary

#undef should not be used. (See page 166 of MISRA-C-2012 [45] , page 168 of MISRA-C-2012-Revision-1 [51] , page 195 of MISRA-C-2023 [58] , page 195 of MISRA-C-2025 [59] .)

Description

Note that, for this service, the report category is the directive name undef.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MC4.R20.5,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=MC4.R20.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=MC4.R20.5,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MC4.R20.6

Aliases

MC3.R20.6, MC3R2.R20.6, MC3A4.R20.6, MC3A3.R20.6, MC3C2.R20.6, MC3A2.R20.6, MC3R1.R20.6, MC3C1.R20.6, MC3A1.R20.6, MC3R0.R20.6

Summary

Tokens that look like a preprocessing directive shall not occur within a macro argument. (See page 166 of MISRA-C-2012 [45] , page 168 of MISRA-C-2012-Revision-1 [51] , page 195 of MISRA-C-2023 [58] , page 195 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option macros
macros
-config=MC4.R20.6,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC3.R20.7

Aliases

MC3R2.R20.7, MC3A4.R20.7, MC3A3.R20.7, MC3C2.R20.7, MC3A2.R20.7, MC3R1.R20.7, MC3C1.R20.7, MC3A1.R20.7, MC3R0.R20.7

Summary

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses. (See page 167 of MISRA-C-2012 [45] , page 169 of MISRA-C-2012-Revision-1 [51] , page 196 of MISRA-C-2023 [58] .)

Description

Any macro invocation argument that expands to a complete expression that is not parenthesized or immediately enclosed in parentheses is reported.

Any macro invocation argument for which the initial and end parts of its expansion begin and end sub-expressions of a single larger expression is reported.

Notes:

  • The arg_expansion service configuration can be used to tag reports for macro invocation arguments that expand to AST nodes;

  • The expansion_context service configuration can be used to tag the reports for macro invocation arguments that expand to nodes with matching contexts.

  • the macros service configuration can be used to tag reports for the selected macros.

For example, the configure lines:

-doc="Macro invocation arguments that always expands to AST nodes are safe."
-config=MC3.R20.7,arg_expansion={safe, safe}
-doc="Expansions in the context of cast to void are safe."
-config=MC3.R20.7,expansion_context={safe, "context(role(to_void))"}

hide any report for a macro invocation argument that always expands to an AST node or for which the macro invocation is in the context of a cast to void.

Configuration

See generic service options.

Option arg_expansion
arg_expansion
-config=MC3.R20.7,arg_expansion={TAGS, OPTION},...

Specify the report tag for the associated macro expansion option.

The configuration’s content is list of report tags and their associated macro expansion option.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

OPTION:

the expansion option. Accepted values are:

  • safe: a macro invocation argument is safe if it always expands to AST nodes;


Option expansion_context
expansion_context
-config=MC3.R20.7,expansion_context={TAGS, MATCHER},...

Specify the report tag for associated expansion context matcher.

The configuration’s content is list of report tags and their associated expansion matcher option.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

expansion context matcher. Accepted forms are:

  • [+]AND_MATCHER: the expansion matches AND_MATCHER

  • -AND_MATCHER: the expansion does not match AND_MATCHER

  • [+]AND_MATCHER||EXP_MATCHER: either the expansion matches AND_MATCHER or it matches EXP_MATCHER

  • -AND_MATCHER||EXP_MATCHER: the expansion does not match AND_MATCHER but does match EXP_MATCHER

EXP_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER||EXP_MATCHER: either the expansion matches BASIC_MATCHER or it matches EXP_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EXP_MATCHER): the expansion matches EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • left_right(REGEX1,REGEX2): the tokens preceding and following the expansion matches, respectively, ^REGEX1$ and ^REGEX2$

  • context(STMT_MATCHER): the expansion is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • single_token(): the expansion is a single token

  • single_expr(): the expansion is a single expression

  • part_of_larger_expr(): the expansion is part of a larger expression

  • pp_expr(PP_MATCHER): the expansion is a preprocessor expression matching PP_EXP_MATCHER

PP_EXP_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the preprocessor expansion matches AND_MATCHER

  • -AND_MATCHER: the preprocessor expansion does not match AND_MATCHER

  • [+]AND_MATCHER||PP_EXP_MATCHER: either the preprocessor expansion matches AND_MATCHER or it matches PP_EXP_MATCHER

  • -AND_MATCHER||PP_EXP_MATCHER: the preprocessor expansion does not match AND_MATCHER but does match PP_EXP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the expansion matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PP_EXP_MATCHER): the expansion matches PP_EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • node(PP_ASTF[||PP_ASTF]*): the expansion’s representation matches one of the preprocessor AST functors

  • operator(PP_OPERATOR[||PP_OPERATOR]*): the expansion’s representation has a main operator that matches one of the preprocessor AST operators

PP_ASTF

accepted forms are:

  • binop: the expansion is a binary operator

  • unnop: the expansion is a unary operator (this includes the defined operator)

  • condop: the expansion is a conditional operator

  • pparen: the expansion is a parenthesized expression

  • pconst: the expansion is a constant value

PP_OPERATOR

accepted forms are:

  • comma: , comma operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • eq: == equality operator

  • ne: != inequality operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • add: + addition operator

  • sub: - subtraction operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • defined: defined operator


Option macros
macros
-config=MC3.R20.7,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R20.7

Aliases

Summary

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses. (See page 196 of MISRA-C-2025 [59] .)

Description

Any macro invocation argument that expands to a complete expression that is not parenthesized or immediately enclosed in parentheses is reported.

Any macro invocation argument for which the initial and end parts of its expansion begin and end sub-expressions of a single larger expression is reported.

Notes:

  • The arg_expansion service configuration can be used to tag reports for macro invocation arguments that expand to AST nodes;

  • The expansion_context service configuration can be used to tag the reports for macro invocation arguments that expand to nodes with matching contexts.

  • the macros service configuration can be used to tag reports for the selected macros.

For example, the configure lines:

-doc="Macro invocation arguments that always expands to AST nodes are safe."
-config=MC4.R20.7,arg_expansion={safe, safe}
-doc="Expansions in the context of cast to void are safe."
-config=MC4.R20.7,expansion_context={safe, "context(role(to_void))"}

hide any report for a macro invocation argument that always expands to an AST node or for which the macro invocation is in the context of a cast to void.

Configuration

See generic service options.

Option arg_expansion
arg_expansion
-config=MC4.R20.7,arg_expansion={TAGS, OPTION},...

Specify the report tag for the associated macro expansion option.

The configuration’s content is list of report tags and their associated macro expansion option.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

OPTION:

the expansion option. Accepted values are:

  • safe: a macro invocation argument is safe if it always expands to AST nodes;


Option expansion_context
expansion_context
-config=MC4.R20.7,expansion_context={TAGS, MATCHER},...

Specify the report tag for associated expansion context matcher.

The configuration’s content is list of report tags and their associated expansion matcher option.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

expansion context matcher. Accepted forms are:

  • [+]AND_MATCHER: the expansion matches AND_MATCHER

  • -AND_MATCHER: the expansion does not match AND_MATCHER

  • [+]AND_MATCHER||EXP_MATCHER: either the expansion matches AND_MATCHER or it matches EXP_MATCHER

  • -AND_MATCHER||EXP_MATCHER: the expansion does not match AND_MATCHER but does match EXP_MATCHER

EXP_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER||EXP_MATCHER: either the expansion matches BASIC_MATCHER or it matches EXP_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EXP_MATCHER): the expansion matches EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • left_right(REGEX1,REGEX2): the tokens preceding and following the expansion matches, respectively, ^REGEX1$ and ^REGEX2$

  • context(STMT_MATCHER): the expansion is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • single_token(): the expansion is a single token

  • single_expr(): the expansion is a single expression

  • part_of_larger_expr(): the expansion is part of a larger expression

  • pp_expr(PP_MATCHER): the expansion is a preprocessor expression matching PP_EXP_MATCHER

PP_EXP_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the preprocessor expansion matches AND_MATCHER

  • -AND_MATCHER: the preprocessor expansion does not match AND_MATCHER

  • [+]AND_MATCHER||PP_EXP_MATCHER: either the preprocessor expansion matches AND_MATCHER or it matches PP_EXP_MATCHER

  • -AND_MATCHER||PP_EXP_MATCHER: the preprocessor expansion does not match AND_MATCHER but does match PP_EXP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the expansion matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PP_EXP_MATCHER): the expansion matches PP_EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • node(PP_ASTF[||PP_ASTF]*): the expansion’s representation matches one of the preprocessor AST functors

  • operator(PP_OPERATOR[||PP_OPERATOR]*): the expansion’s representation has a main operator that matches one of the preprocessor AST operators

PP_ASTF

accepted forms are:

  • binop: the expansion is a binary operator

  • unnop: the expansion is a unary operator (this includes the defined operator)

  • condop: the expansion is a conditional operator

  • pparen: the expansion is a parenthesized expression

  • pconst: the expansion is a constant value

PP_OPERATOR

accepted forms are:

  • comma: , comma operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • eq: == equality operator

  • ne: != inequality operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • add: + addition operator

  • sub: - subtraction operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • defined: defined operator


Option macros
macros
-config=MC4.R20.7,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R20.8

Aliases

MC3.R20.8, MC3R2.R20.8, MC3A4.R20.8, MC3A3.R20.8, MC3C2.R20.8, MC3A2.R20.8, MC3R1.R20.8, MC3C1.R20.8, MC3A1.R20.8, MC3R0.R20.8

Summary

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1. (See page 168 of MISRA-C-2012 [45] , page 170 of MISRA-C-2012-Revision-1 [51] , page 197 of MISRA-C-2023 [58] , page 197 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R20.9

Aliases

MC3.R20.9, MC3R2.R20.9, MC3A4.R20.9, MC3A3.R20.9, MC3C2.R20.9, MC3A2.R20.9, MC3R1.R20.9, MC3C1.R20.9, MC3A1.R20.9, MC3R0.R20.9

Summary

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation. (See page 169 of MISRA-C-2012 [45] , page 171 of MISRA-C-2012-Revision-1 [51] , page 198 of MISRA-C-2023 [58] , page 198 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R20.10

Aliases

MC3.R20.10, MC3R2.R20.10, MC3A4.R20.10, MC3A3.R20.10, MC3C2.R20.10, MC3A2.R20.10, MC3R1.R20.10, MC3C1.R20.10, MC3A1.R20.10, MC3R0.R20.10

Summary

The # and ## preprocessor operators should not be used. (See page 170 of MISRA-C-2012 [45] , page 172 of MISRA-C-2012-Revision-1 [51] , page 199 of MISRA-C-2023 [58] , page 199 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option macros
macros
-config=MC4.R20.10,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R20.11

Aliases

MC3.R20.11, MC3R2.R20.11, MC3A4.R20.11, MC3A3.R20.11, MC3C2.R20.11, MC3A2.R20.11, MC3R1.R20.11, MC3C1.R20.11, MC3A1.R20.11, MC3R0.R20.11

Summary

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator. (See page 170 of MISRA-C-2012 [45] , page 172 of MISRA-C-2012-Revision-1 [51] , page 199 of MISRA-C-2023 [58] , page 199 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option macros
macros
-config=MC4.R20.11,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R20.12

Aliases

MC3.R20.12, MC3R2.R20.12, MC3A4.R20.12, MC3A3.R20.12, MC3C2.R20.12, MC3A2.R20.12, MC3R1.R20.12, MC3C1.R20.12, MC3A1.R20.12, MC3R0.R20.12

Summary

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators. (See page 171 of MISRA-C-2012 [45] , page 173 of MISRA-C-2012-Revision-1 [51] , page 200 of MISRA-C-2023 [58] , page 200 of MISRA-C-2025 [59] .)

Description

A macro is reported if:

  • a parameter occurs in the body both:

    • as an operand to a # or ## operand, and

    • not as an operand to a # or ## operand, and

  • in an invocation of the macro, an argument matching this parameter includes an expanded macro.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R20.12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R20.13

Aliases

MC3.R20.13, MC3R2.R20.13, MC3A4.R20.13, MC3A3.R20.13, MC3C2.R20.13, MC3A2.R20.13, MC3R1.R20.13, MC3C1.R20.13, MC3A1.R20.13, MC3R0.R20.13

Summary

A line whose first token is # shall be a valid preprocessing directive. (See page 171 of MISRA-C-2012 [45] , page 173 of MISRA-C-2012-Revision-1 [51] , page 201 of MISRA-C-2023 [58] , page 201 of MISRA-C-2025 [59] .)

Description

A preprocessing directive is reported if:

  • it is not one of the preprocessing tokens specified in Section 6.10 of the C99 standard [37];

  • it is a conditional directive that does not follow the pattern specified in Section 6.8 of the C90 standard [34]; or

  • it is an #else or #endif directive that is not followed by a whitespace.

Note also that any parsing errors in the preprocessing code that is not excluded by conditional compilation is reported by the service B.PARSER.

Note that, for this service, the report category is the directive name.

This service depends upon the configuration of the following ancillary services: STD.prepdirc

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC4.R20.13,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC4.R20.14

Aliases

MC3.R20.14, MC3R2.R20.14, MC3A4.R20.14, MC3A3.R20.14, MC3C2.R20.14, MC3A2.R20.14, MC3R1.R20.14, MC3C1.R20.14, MC3A1.R20.14, MC3R0.R20.14

Summary

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related. (See page 172 of MISRA-C-2012 [45] , page 174 of MISRA-C-2012-Revision-1 [51] , page 18 of MISRA-C-2012-TC2 [54] , page 202 of MISRA-C-2023 [58] , page 202 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R20.15

Aliases

Summary

#define and #undef shall not be used on a reserved identifier or reserved macro name. (See page 203 of MISRA-C-2025 [59] .)

Description

The reserved identifiers are defined to be the identifiers in file scope that are reserved by the standard used by the translation unit.

Note that reserved identifier does not include keywords (see service R20.4).

The default configuration checks identifiers that are reserved by the standard library; to specify that identifiers provided by the project standard library posix are also reserved, use the -stdlib global configuration with the reserved_standard service configuration. For example, with the configuration lines:

-+stdlib=posix
-config=MC4.R20.15,reserved_standard+="posix"

the reserved identifiers in the posix library will be checked.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+={my_lib, c, 2022, c, "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)", "file_scope"}

Then with the service configuration line

-config=MC4.R20.15,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC4.R20.15,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC4.R20.15,reserved_standard="std()"

Option macros
macros
-config=MC4.R20.15,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=MC4.R20.15,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC3.R21.1

Aliases

MC3R2.R21.1, MC3A4.R21.1, MC3A3.R21.1, MC3C2.R21.1, MC3A2.R21.1, MC3R1.R21.1, MC3C1.R21.1, MC3A1.R21.1, MC3R0.R21.1

Summary

#define and #undef shall not be used on a reserved identifier or reserved macro name. (See page 173 of MISRA-C-2012 [45] , page 175 of MISRA-C-2012-Revision-1 [51] , page 16 of MISRA-C-2012-TC1 [48] , page 203 of MISRA-C-2023 [58] .)

Description

The reserved identifiers are defined to be the identifiers in file scope that are reserved by the standard used by the translation unit.

Note that reserved identifier does not include keywords (see service R20.4).

The default configuration checks identifiers that are reserved by the standard library; to specify that identifiers provided by the project standard library posix are also reserved, use the -stdlib global configuration with the reserved_standard service configuration. For example, with the configuration lines:

-+stdlib=posix
-config=MC3.R21.1,reserved_standard+="posix"

the reserved identifiers in the posix library will be checked.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+={my_lib, c, 2022, c, "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)", "file_scope"}

Then with the service configuration line

-config=MC3.R21.1,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC3.R21.1,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC3.R21.1,reserved_standard="std()"

Option macros
macros
-config=MC3.R21.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=MC3.R21.1,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC3A1.R21.2

Aliases

MC3R0.R21.2

Summary

A reserved identifier or macro name shall not be declared. (See page 174 of MISRA-C-2012 [45] .)

Description

The reserved identifiers are defined to be any names that begin with an underscore or identifiers in file scope that are reserved by the standard used by the translation unit.

The reserved macros are defined to be any names that begin with an underscore or macros that are reserved by the standard used by the translation unit.

If the compiler language is C++, then namespace and tag qualifiers are considered relevant.

Note that this rule is only for non-preprocessor identifiers such as objects, function names and typedefs.

The default configuration checks identifiers that are reserved by the standard library; to specify that identifiers provided by the project standard library posix are also reserved, use the -stdlib global configuration with the reserved_standard service configuration. For example, with the configuration lines:

-+stdlib=posix
-config=MC3A1.R21.2,reserved_standard+="posix"

the reserved identifiers in the posix library will be checked.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+={my_lib, c, 2022, c, "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)", "file_scope"}

Then with the service configuration line

-config=MC3A1.R21.2,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC3A1.R21.2,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC3A1.R21.2,reserved_standard="std()"

Option declarations
declarations
-config=MC3A1.R21.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3.R21.2

Aliases

MC3R2.R21.2, MC3A4.R21.2, MC3A3.R21.2, MC3C2.R21.2, MC3A2.R21.2, MC3R1.R21.2, MC3C1.R21.2

Summary

A reserved identifier or reserved macro name shall not be declared. (See page 16 of MISRA-C-2012-TC1 [48] , page 176 of MISRA-C-2012-Revision-1 [51] , page 204 of MISRA-C-2023 [58] .)

Description

The reserved identifiers are defined to be any names that begin with an underscore or identifiers in file scope that are reserved by the standard used by the translation unit.

The reserved macros are defined to be any names that begin with an underscore or macros that are reserved by the standard used by the translation unit.

If the compiler language is C++, then namespace and tag qualifiers are considered relevant.

Note that this rule is only for non-preprocessor identifiers such as objects, function names and typedefs.

The default configuration checks identifiers that are reserved by the standard library; to specify that identifiers provided by the project standard library posix are also reserved, use the -stdlib global configuration with the reserved_standard service configuration. For example, with the configuration lines:

-+stdlib=posix
-config=MC3.R21.2,reserved_standard+="posix"

the reserved identifiers in the posix library will be checked.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+={my_lib, c, 2022, c, "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)", "file_scope"}

Then with the service configuration line

-config=MC3.R21.2,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC3.R21.2,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC3.R21.2,reserved_standard="std()"

Option declarations
declarations
-config=MC3.R21.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R21.3

Aliases

MC3.R21.3, MC3R2.R21.3, MC3A4.R21.3, MC3A3.R21.3, MC3C2.R21.3, MC3A2.R21.3, MC3R1.R21.3, MC3C1.R21.3, MC3A1.R21.3, MC3R0.R21.3

Summary

The memory allocation and deallocation functions of <stdlib.h> shall not be used. (See page 175 of MISRA-C-2012 [45] , page 177 of MISRA-C-2012-Revision-1 [51] , page 23 of MISRA-C-2012-Amendment-2 [52] , page 205 of MISRA-C-2023 [58] , page 205 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R21.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC4.R21.3,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R21.4

Aliases

MC3.R21.4, MC3R2.R21.4, MC3A4.R21.4, MC3A3.R21.4, MC3C2.R21.4, MC3A2.R21.4, MC3R1.R21.4, MC3C1.R21.4, MC3A1.R21.4, MC3R0.R21.4

Summary

The standard header file <setjmp.h> shall not be used. (See page 176 of MISRA-C-2012 [45] , page 178 of MISRA-C-2012-Revision-1 [51] , page 206 of MISRA-C-2023 [58] , page 206 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R21.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC4.R21.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R21.5

Aliases

MC3.R21.5, MC3R2.R21.5, MC3A4.R21.5, MC3A3.R21.5, MC3C2.R21.5, MC3A2.R21.5, MC3R1.R21.5, MC3C1.R21.5, MC3A1.R21.5, MC3R0.R21.5

Summary

The standard header file <signal.h> shall not be used. (See page 176 of MISRA-C-2012 [45] , page 178 of MISRA-C-2012-Revision-1 [51] , page 206 of MISRA-C-2023 [58] , page 206 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R21.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC4.R21.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R21.6

Aliases

MC3.R21.6, MC3R2.R21.6, MC3A4.R21.6, MC3A3.R21.6, MC3C2.R21.6, MC3A2.R21.6, MC3R1.R21.6, MC3C1.R21.6, MC3A1.R21.6, MC3R0.R21.6

Summary

The Standard Library input/output functions shall not be used. (See page 176 of MISRA-C-2012 [45] , page 178 of MISRA-C-2012-Revision-1 [51] , page 23 of MISRA-C-2012-Amendment-2 [52] , page 207 of MISRA-C-2023 [58] , page 207 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R21.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC4.R21.6,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC3A1.R21.7

Aliases

MC3R0.R21.7

Summary

The library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used. (See page 177 of MISRA-C-2012 [45] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC3A1.R21.7,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC3A1.R21.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R21.7

Aliases

MC3.R21.7, MC3R2.R21.7, MC3A4.R21.7, MC3A3.R21.7, MC3C2.R21.7, MC3A2.R21.7, MC3R1.R21.7, MC3C1.R21.7

Summary

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used. (See page 17 of MISRA-C-2012-TC1 [48] , page 179 of MISRA-C-2012-Revision-1 [51] , page 23 of MISRA-C-2012-Amendment-2 [52] , page 207 of MISRA-C-2023 [58] , page 207 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R21.7,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC4.R21.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3R0.R21.8

Aliases

Summary

The library functions abort, exit, getenv and system of <stdlib.h> shall not be used. (See page 177 of MISRA-C-2012 [45] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC3R0.R21.8,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC3R0.R21.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3A1.R21.8

Aliases

Summary

The library functions abort, exit and system of <stdlib.h> shall not be used. (See page 25 of MISRA-C-2012-Amendment-1 [46] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC3A1.R21.8,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC3A1.R21.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3R1.R21.8

Aliases

MC3C1.R21.8

Summary

The Standard Library functions abort, exit and system of <stdlib.h> shall not be used. (See page 179 of MISRA-C-2012-Revision-1 [51] , page 17 of MISRA-C-2012-TC1 [48] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC3R1.R21.8,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC3R1.R21.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R21.8

Aliases

MC3.R21.8, MC3R2.R21.8, MC3A4.R21.8, MC3A3.R21.8, MC3C2.R21.8, MC3A2.R21.8

Summary

The Standard Library termination functions of <stdlib.h> shall not be used. (See page 24 of MISRA-C-2012-Amendment-2 [52] , page 208 of MISRA-C-2023 [58] , page 208 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R21.8,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC4.R21.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC3A1.R21.9

Aliases

MC3R0.R21.9

Summary

The library functions bsearch and qsort of <stdlib.h> shall not be used. (See page 178 of MISRA-C-2012 [45] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC3A1.R21.9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC3A1.R21.9,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R21.9

Aliases

MC3.R21.9, MC3R2.R21.9, MC3A4.R21.9, MC3A3.R21.9, MC3C2.R21.9, MC3A2.R21.9, MC3R1.R21.9, MC3C1.R21.9

Summary

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used. (See page 18 of MISRA-C-2012-TC1 [48] , page 180 of MISRA-C-2012-Revision-1 [51] , page 208 of MISRA-C-2023 [58] , page 208 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R21.9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC4.R21.9,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R21.10

Aliases

MC3.R21.10, MC3R2.R21.10, MC3A4.R21.10, MC3A3.R21.10, MC3C2.R21.10, MC3A2.R21.10, MC3R1.R21.10, MC3C1.R21.10, MC3A1.R21.10, MC3R0.R21.10

Summary

The Standard Library time and date functions shall not be used. (See page 178 of MISRA-C-2012 [45] , page 180 of MISRA-C-2012-Revision-1 [51] , page 24 of MISRA-C-2012-Amendment-2 [52] , page 209 of MISRA-C-2023 [58] , page 209 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R21.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC4.R21.10,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC3C2.R21.11

Aliases

MC3A2.R21.11, MC3R1.R21.11, MC3C1.R21.11, MC3A1.R21.11, MC3R0.R21.11

Summary

The standard header file <tgmath.h> shall not be used. (See page 179 of MISRA-C-2012 [45] , page 181 of MISRA-C-2012-Revision-1 [51] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC3C2.R21.11,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC4.R21.11

Aliases

MC3.R21.11, MC3R2.R21.11, MC3A4.R21.11, MC3A3.R21.11

Summary

The standard header file <tgmath.h> should not be used. (See page 30 of MISRA-C-2012-Amendment-3 [55] , page 209 of MISRA-C-2023 [58] , page 209 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R21.11,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC3C2.R21.12

Aliases

MC3A2.R21.12, MC3R1.R21.12, MC3C1.R21.12, MC3A1.R21.12, MC3R0.R21.12

Summary

The exception handling features of <fenv.h> should not be used. (See page 179 of MISRA-C-2012 [45] , page 181 of MISRA-C-2012-Revision-1 [51] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC3C2.R21.12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC3C2.R21.12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R21.12

Aliases

MC3.R21.12, MC3R2.R21.12, MC3A4.R21.12, MC3A3.R21.12

Summary

The standard header file <fenv.h> shall not be used. (See page 31 of MISRA-C-2012-Amendment-3 [55] , page 210 of MISRA-C-2023 [58] , page 210 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R21.12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC4.R21.12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R21.13

Aliases

MC3.R21.13, MC3R2.R21.13, MC3A4.R21.13, MC3A3.R21.13, MC3C2.R21.13, MC3A2.R21.13, MC3R1.R21.13, MC3C1.R21.13, MC3A1.R21.13

Summary

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF. (See page 12 of MISRA-C-2012-Amendment-1 [46] , page 182 of MISRA-C-2012-Revision-1 [51] , page 211 of MISRA-C-2023 [58] , page 211 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported when the argument’s value has not been determined and may not be representable as unsigned char.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.13,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R21.13,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R21.14

Aliases

MC3.R21.14, MC3R2.R21.14, MC3A4.R21.14, MC3A3.R21.14, MC3C2.R21.14, MC3A2.R21.14, MC3R1.R21.14, MC3C1.R21.14, MC3A1.R21.14

Summary

The Standard Library function memcmp shall not be used to compare null terminated strings. (See page 12 of MISRA-C-2012-Amendment-1 [46] , page 183 of MISRA-C-2012-Revision-1 [51] , page 212 of MISRA-C-2023 [58] , page 212 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported when it cannot be determined whether the compared expressions are strings.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.14,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R21.14,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R21.15

Aliases

MC3.R21.15, MC3R2.R21.15, MC3A4.R21.15, MC3A3.R21.15, MC3C2.R21.15, MC3A2.R21.15, MC3R1.R21.15, MC3C1.R21.15, MC3A1.R21.15

Summary

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types. (See page 14 of MISRA-C-2012-Amendment-1 [46] , page 184 of MISRA-C-2012-Revision-1 [51] , page 213 of MISRA-C-2023 [58] , page 213 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Rule MC4.R21.16

Aliases

MC3.R21.16, MC3R2.R21.16, MC3A4.R21.16, MC3A3.R21.16, MC3C2.R21.16, MC3A2.R21.16, MC3R1.R21.16, MC3C1.R21.16, MC3A1.R21.16

Summary

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type. (See page 14 of MISRA-C-2012-Amendment-1 [46] , page 185 of MISRA-C-2012-Revision-1 [51] , page 214 of MISRA-C-2023 [58] , page 214 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.16,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R21.16,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R21.17

Aliases

MC3.R21.17, MC3R2.R21.17, MC3A4.R21.17, MC3A3.R21.17, MC3C2.R21.17, MC3A2.R21.17, MC3R1.R21.17, MC3C1.R21.17, MC3A1.R21.17

Summary

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters. (See page 16 of MISRA-C-2012-Amendment-1 [46] , page 186 of MISRA-C-2012-Revision-1 [51] , page 215 of MISRA-C-2023 [58] , page 215 of MISRA-C-2025 [59] .)

Description

It is reported (as a caution) if an array of character type whose size is known and is initialized by a character string literal that is too long for the array to include the terminating null character

Imprecision

Cautions are reported for every suspect case found.

False negatives are present when the size of the argument has not been determined.

For example, in:

int main(int argc, char **argv) {
  char dst[10];
  strcpy(dst, argv[0]);
  }

the call to strcpy is not reported.

Configuration

See generic service options.

Rule MC4.R21.18

Aliases

MC3.R21.18, MC3R2.R21.18, MC3A4.R21.18, MC3A3.R21.18, MC3C2.R21.18, MC3A2.R21.18, MC3R1.R21.18, MC3C1.R21.18, MC3A1.R21.18

Summary

The size_t argument passed to any function in <string.h> shall have an appropriate value. (See page 17 of MISRA-C-2012-Amendment-1 [46] , page 187 of MISRA-C-2012-Revision-1 [51] , page 216 of MISRA-C-2023 [58] , page 216 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported when the value of the size_t argument or the size of a pointer argument has not been determined.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.18,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MC4.R21.19

Aliases

MC3.R21.19, MC3R2.R21.19, MC3A4.R21.19, MC3A3.R21.19, MC3C2.R21.19, MC3A2.R21.19, MC3R1.R21.19, MC3C1.R21.19, MC3A1.R21.19

Summary

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type. (See page 18 of MISRA-C-2012-Amendment-1 [46] , page 188 of MISRA-C-2012-Revision-1 [51] , page 217 of MISRA-C-2023 [58] , page 217 of MISRA-C-2025 [59] .)

Description

Notes:

  • once the returned value is assigned to a const pointer further assignments by the assignee are not checked to see if the const is removed.

  • assigning the returned value to a non-const pointer is reported as a violation.

  • passing the returned value to a function where its use is unknown is reported as a caution.

  • Note that to specify the write properties for a called function’s arguments, use the -call_properties global configuration with property pointee_write for the write properties of non-const parameters and const_pointee_write for the write properties of const parameters.

For example, with the configuration line:

-call_properties+={"decl(name(safe_fun))",
   {"pointee_write(1..=never)"}}

a pointer returned by one of the standard library functions localeconv, getenv, setlocale or strerror and used in the first argument in a call to the function safe_fun is not reported.

Imprecision

Cautions are reported when the returned value is passed to a function and it is unknown how the function may use the value.

Configuration

See generic service options.

Rule MC4.R21.20

Aliases

MC3.R21.20, MC3R2.R21.20, MC3A4.R21.20, MC3A3.R21.20, MC3C2.R21.20, MC3A2.R21.20, MC3R1.R21.20, MC3C1.R21.20, MC3A1.R21.20

Summary

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function. (See page 19 of MISRA-C-2012-Amendment-1 [46] , page 190 of MISRA-C-2012-Revision-1 [51] , page 219 of MISRA-C-2023 [58] , page 219 of MISRA-C-2025 [59] .)

Description

Two functions calls are considered to be calls to similar functions if:

  • the first is a call to the localeconv function and the second a call to the setlocale function;

  • the calls are to the asctime and ctime functions;

  • the calls are to the gmtime and localtime functions.

Imprecision

Cautions are reported when the control flow or the use of the returned value has not been fully determined.

A caution may be reported when there is a call to one of the library functions and:

  • the return value is assigned to a variable and it has not been determined if a second call follows this call before the variable is checked;

  • the return value is assigned to a local variable but this may have been assigned to another variable;

  • the return value is assigned to a non-local variable or parameter;

  • the return value for a call to one of the library functions is not saved but returned to the callee.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.20,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MC4.R21.21

Aliases

MC3.R21.21, MC3R2.R21.21, MC3A4.R21.21, MC3A3.R21.21, MC3C2.R21.21, MC3A2.R21.21

Summary

The Standard Library function system of <stdlib.h> shall not be used. (See page 25 of MISRA-C-2012-Amendment-2 [52] , page 220 of MISRA-C-2023 [58] , page 220 of MISRA-C-2025 [59] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R21.21,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC4.R21.21,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R21.22

Aliases

MC3.R21.22, MC3R2.R21.22, MC3A4.R21.22, MC3A3.R21.22

Summary

All operand arguments to any type-generic macros declared in <tgmath.h> shall have an appropriate essential type. (See page 32 of MISRA-C-2012-Amendment-3 [55] , page 220 of MISRA-C-2023 [58] , page 220 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.22,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R21.22,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R21.23

Aliases

MC3.R21.23, MC3R2.R21.23, MC3A4.R21.23, MC3A3.R21.23

Summary

All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type. (See page 33 of MISRA-C-2012-Amendment-3 [55] , page 222 of MISRA-C-2023 [58] , page 222 of MISRA-C-2025 [59] .)

Description

The rule is not applicable to macros frexp, remquo, ldexp, scalbn and scalbln because only the first argument is type-generic.

Configuration

See generic service options.

Rule MC4.R21.24

Aliases

MC3.R21.24, MC3R2.R21.24, MC3A4.R21.24, MC3A3.R21.24

Summary

The random number generator functions of <stdlib.h> shall not be used. (See page 34 of MISRA-C-2012-Amendment-3 [55] , page 223 of MISRA-C-2023 [58] , page 223 of MISRA-C-2025 [59] .)

Description

Any expanded macro with the same name is also reported, even if defined outside of stdlib.h

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC4.R21.24,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC4.R21.24,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R21.25

Aliases

MC3.R21.25, MC3R2.R21.25, MC3A4.R21.25

Summary

All memory synchronization operations shall be executed in sequentially consistent order. (See page 25 of MISRA-C-2012-Amendment-4 [57] , page 223 of MISRA-C-2023 [58] , page 223 of MISRA-C-2025 [59] .)

Description

Memory synchronization functions with names ending with _explicit that do not have memory_order_seq_cst for the final argument are shown

Imprecision

False positives are possible when the memory order passed to the memory synchronization functions is stored in a variable

Reports as cautions instances of calls to the memory synchronization functions that have an memory order not specified as the enumeration constant memory_order_seq_cst

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.25,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R21.25,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R21.26

Aliases

MC3.R21.26, MC3R2.R21.26, MC3A4.R21.26

Summary

The Standard Library function mtx_timedlock() shall only be invoked on mutex objects of appropriate mutex type. (See page 26 of MISRA-C-2012-Amendment-4 [57] , page 225 of MISRA-C-2023 [58] , page 225 of MISRA-C-2025 [59] .)

Imprecision

False positives are reported due to the undecidability of the rule

All invocations of mtx_timedlock are reported

Configuration

See generic service options.

Option calls
calls
-config=MC4.R21.26,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R21.26,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.1

Aliases

MC3.R22.1, MC3R2.R22.1, MC3A4.R22.1, MC3A3.R22.1, MC3C2.R22.1, MC3A2.R22.1, MC3R1.R22.1, MC3C1.R22.1, MC3A1.R22.1, MC3R0.R22.1

Summary

All resources obtained dynamically by means of Standard Library functions shall be explicitly released. (See page 180 of MISRA-C-2012 [45] , page 190 of MISRA-C-2012-Revision-1 [51] , page 25 of MISRA-C-2012-Amendment-2 [52] , page 226 of MISRA-C-2023 [58] , page 226 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported for every suspect case found.

False negatives are present when the checker precision is insufficient.

Configuration

See generic service options.

Rule MC4.R22.2

Aliases

MC3.R22.2, MC3R2.R22.2, MC3A4.R22.2, MC3A3.R22.2, MC3C2.R22.2, MC3A2.R22.2, MC3R1.R22.2, MC3C1.R22.2, MC3A1.R22.2, MC3R0.R22.2

Summary

A block of memory shall only be freed if it was allocated by means of a Standard Library function. (See page 182 of MISRA-C-2012 [45] , page 192 of MISRA-C-2012-Revision-1 [51] , page 227 of MISRA-C-2023 [58] , page 227 of MISRA-C-2025 [59] .)

Description

This rule reports possible memory problems as cautions.

Imprecision

Cautions are reported for every suspect case found.

False negatives are present when the checker precision is insufficient.

Configuration

See generic service options.

Rule MC4.R22.3

Aliases

MC3.R22.3, MC3R2.R22.3, MC3A4.R22.3, MC3A3.R22.3, MC3C2.R22.3, MC3A2.R22.3, MC3R1.R22.3, MC3C1.R22.3, MC3A1.R22.3, MC3R0.R22.3

Summary

The same file shall not be open for read and write access at the same time on different streams. (See page 183 of MISRA-C-2012 [45] , page 193 of MISRA-C-2012-Revision-1 [51] , page 228 of MISRA-C-2023 [58] , page 228 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported for all calls to fopen with read access or with write access.

Configuration

See generic service options.

Rule MC4.R22.4

Aliases

MC3.R22.4, MC3R2.R22.4, MC3A4.R22.4, MC3A3.R22.4, MC3C2.R22.4, MC3A2.R22.4, MC3R1.R22.4, MC3C1.R22.4, MC3A1.R22.4, MC3R0.R22.4

Summary

There shall be no attempt to write to a stream which has been opened as read-only. (See page 184 of MISRA-C-2012 [45] , page 194 of MISRA-C-2012-Revision-1 [51] , page 229 of MISRA-C-2023 [58] , page 229 of MISRA-C-2025 [59] .)

Imprecision

Cautions are reported for all calls to fopen with possibly read-only access.

Configuration

See generic service options.

Rule MC4.R22.5

Aliases

MC3.R22.5, MC3R2.R22.5, MC3A4.R22.5, MC3A3.R22.5, MC3C2.R22.5, MC3A2.R22.5, MC3R1.R22.5, MC3C1.R22.5, MC3A1.R22.5, MC3R0.R22.5

Summary

A pointer to a FILE object shall not be dereferenced. (See page 184 of MISRA-C-2012 [45] , page 194 of MISRA-C-2012-Revision-1 [51] , page 25 of MISRA-C-2012-Amendment-2 [52] , page 229 of MISRA-C-2023 [58] , page 229 of MISRA-C-2025 [59] .)

Description

It will be reported if:

  • an argument of ->, *, . has the same type as that of the FILE typedef;

  • sizeof or __alignof__ argument is a type that is the same as that of FILE or is an expression of type FILE;

  • an implicit cast from an lvalue to an rvalue has the same type as that of the FILE typedef;

  • there is a cast from FILE* to any type that is different from that of FILE typedef (in this case the report is a caution).

Imprecision

Cautions are reported when there is a cast from FILE* to any type that is different from that of FILE typedef.

Configuration

See generic service options.

Rule MC4.R22.6

Aliases

MC3.R22.6, MC3R2.R22.6, MC3A4.R22.6, MC3A3.R22.6, MC3C2.R22.6, MC3A2.R22.6, MC3R1.R22.6, MC3C1.R22.6, MC3A1.R22.6, MC3R0.R22.6

Summary

The value of a pointer to a FILE shall not be used after the associated stream has been closed. (See page 185 of MISRA-C-2012 [45] , page 195 of MISRA-C-2012-Revision-1 [51] , page 230 of MISRA-C-2023 [58] , page 230 of MISRA-C-2025 [59] .)

Description

Standard library functions that use or close a resource with type FILE* are checked.

  • Calls to the function fclose are reported if the resource is one of stderr, stdin or stdout;

  • calls to functions that use the resource are reported if the resource is not one of stderr, stdin or stdout.

Imprecision

Any function that uses a resource with type FILE* is reported as caution.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.6,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R22.6,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.7

Aliases

MC3.R22.7, MC3R2.R22.7, MC3A4.R22.7, MC3A3.R22.7, MC3C2.R22.7, MC3A2.R22.7, MC3R1.R22.7, MC3C1.R22.7, MC3A1.R22.7

Summary

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF. (See page 20 of MISRA-C-2012-Amendment-1 [46] , page 196 of MISRA-C-2012-Revision-1 [51] , page 231 of MISRA-C-2023 [58] , page 231 of MISRA-C-2025 [59] .)

Imprecision

False positives are reported when feof or ferror are used to check the stream status.

False negatives are present when the tests for EOF does not immediately follow the call.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.7,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MC4.R22.8

Aliases

MC3.R22.8, MC3R2.R22.8, MC3A4.R22.8, MC3A3.R22.8, MC3C2.R22.8, MC3A2.R22.8, MC3R1.R22.8, MC3C1.R22.8, MC3A1.R22.8

Summary

The value of errno shall be set to zero prior to a call to an * errno-setting-function*. (See page 21 of MISRA-C-2012-Amendment-1 [46] , page 197 of MISRA-C-2012-Revision-1 [51] , page 232 of MISRA-C-2023 [58] , page 232 of MISRA-C-2025 [59] .)

Description

For a list of error-setting functions referred to here, see Rule 22.8 in the MISRA C document.

Imprecision

Cautions are reported when errno is set to 0 by a called function.

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.8,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MC4.R22.9

Aliases

MC3.R22.9, MC3R2.R22.9, MC3A4.R22.9, MC3A3.R22.9, MC3C2.R22.9, MC3A2.R22.9, MC3R1.R22.9, MC3C1.R22.9, MC3A1.R22.9

Summary

The value of errno shall be tested against zero after calling an * errno-setting-function*. (See page 22 of MISRA-C-2012-Amendment-1 [46] , page 198 of MISRA-C-2012-Revision-1 [51] , page 19 of MISRA-C-2012-TC2 [54] , page 233 of MISRA-C-2023 [58] , page 233 of MISRA-C-2025 [59] .)

Description

For a list of errno-setting functions referred to here, see Rule 22.8, page 232 MISRA C:2023 [58] .

Imprecision

Cautions are reported when the checker cannot identify whether a complex test is for zero.

Complex tests for zero may not be identified as such:

errno = 0;
float fl;
fl = strtof("12345678901234567890123456789012345678901234567890",
            NULL);
if (errno > -1 && errno < 2 && errno != 1)
  return 0;

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.9,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option handling
handling
-config=MC4.R22.9,handling={DECL_MATCHER, ID, SLCT, {{TAG, ACTION, FMT},...}},...

Specify the error handling.

The configuration’s content is an ordered list of a declaration matcher for the calling function, an error identifier and associated data about where the error is placed, where it should be tested and what actions should be taken.

Note that the first matching clause for the calling function and error identifier will be selected and the error value is checked using the associated data

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

ID:

an identifier declared in the -function_error global configuration.

SLCT:

specifies if handling is in a switch or if statement. Accepted values are:

  • any: any selection;

  • if: if statement;

  • switch: switch statement;

TAG:

a value tag declared in the -function_error global configuration.

ACTION:

action to be taken at end of related error branch. Accepted forms are:

  • any: the action is not checked

  • return_any(): the action is to return

  • return(RETURN_VAL): the action is to return RETURN_VAL

  • return_minus(RETURN_VAL): the action is to return the negated RETURN_VAL

  • return_call(CALL_MATCHER,RETURN_VAL): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression) where the RETURN_VAL is an argument to the call; the called function must have a noreturn attribute (see the -decl_properties global configuration)

  • goto(REGEX): the action is a goto statement with label matching REGEX

  • throw(TYPE_MATCHER): the action is a throw statement with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • call(CALL_MATCHER): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression)

  • switch(FUNCTION_ERROR): the action is a switch statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

  • if(FUNCTION_ERROR): the action is an if statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

REGEX

accepted forms are:

RETURN_VAL

accepted forms are:

  • return_value(): the returned value

  • INTEGER: the value

  • STMT_MATCHER: a sub-expression of an expression matching STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template callpost__default_fmt) to specify the message describing ACTION.

Default:

-config=MC4.R22.9,handling={"any()", __errno_nonzero_errors, any, {}}

Rule MC4.R22.10

Aliases

MC3.R22.10, MC3R2.R22.10, MC3A4.R22.10, MC3A3.R22.10, MC3C2.R22.10, MC3A2.R22.10, MC3R1.R22.10, MC3C1.R22.10, MC3A1.R22.10

Summary

The value of errno shall only be tested when the last function to be called was an errno-setting-function. (See page 23 of MISRA-C-2012-Amendment-1 [46] , page 199 of MISRA-C-2012-Revision-1 [51] , page 234 of MISRA-C-2023 [58] , page 234 of MISRA-C-2025 [59] .)

Description

For a list of errno-setting functions referred to here, see Rule 22.8, page 232 MISRA C:2023 [58] .

Imprecision

Cautions are reported when the checker cannot identify whether a complex test is for zero.

Complex tests for zero may not be identified as such:

errno = 0;
float fl;
fl = strtof("12345678901234567890123456789012345678901234567890",
            NULL);
if (errno > -1 && errno < 2 && errno != 1)
  return 0;

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.10,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MC4.R22.11

Aliases

MC3.R22.11, MC3R2.R22.11, MC3A4.R22.11

Summary

A thread that was previously either joined or detached shall not be subsequently joined nor detached. (See page 27 of MISRA-C-2012-Amendment-4 [57] , page 235 of MISRA-C-2023 [58] , page 235 of MISRA-C-2025 [59] .)

Imprecision

False positives are present due to the undecidability of the rule.

Reports as cautions calls to thread synchronization functions thrd_join and thrd_detach that are not the cause of undefined behaviour

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.11,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R22.11,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.12

Aliases

MC3.R22.12, MC3R2.R22.12, MC3A4.R22.12

Summary

Thread objects, thread synchronization objects, and thread-specific storage pointers shall only be accessed by the appropriate Standard Library functions. (See page 28 of MISRA-C-2012-Amendment-4 [57] , page 236 of MISRA-C-2023 [58] , page 236 of MISRA-C-2025 [59] .)

Description

Objects of type thrd_t (or pointers thereof) shall be used only as arguments of the thrd_create, thrd_equal, thrd_detach functions. Objects of type mtx_t (or pointers thereof) shall be used only as arguments of the mtx_init, mtx_destroy, mtx_lock, mtx_trylock, mtx_timedlock, mtx_unlock, cnd_wait, cnd_timedwait functions. Objects of type cnd_t (or pointers thereof) shall be used only as arguments of the cnd_init, cnd_destroy, cnd_signal, cnd_wait, cnd_timedwait functions. Object of type tss_t (or pointers thereof) shall be used only as arguments of the tss_create, tss_destroy, tss_get, tss_set functions.

Imprecision

False positives are possible due to the undecidability of the rule

Some uses of the objects mentioned by the rule may be reported as cautions even when not modified or used in the manner indicated in the rule amplification

Configuration

See generic service options.

Option statements
statements
-config=MC4.R22.12,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R22.12,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.13

Aliases

MC3.R22.13, MC3R2.R22.13, MC3A4.R22.13

Summary

Thread objects, thread synchronization objects and thread-specific storage pointers shall have appropriate storage duration. (See page 29 of MISRA-C-2012-Amendment-4 [57] , page 237 of MISRA-C-2023 [58] , page 237 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R22.13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC4.R22.14

Aliases

MC3.R22.14, MC3R2.R22.14, MC3A4.R22.14

Summary

Thread synchronization objects shall be initialized before being accessed. (See page 30 of MISRA-C-2012-Amendment-4 [57] , page 238 of MISRA-C-2023 [58] , page 238 of MISRA-C-2025 [59] .)

Imprecision

Invocations of mtx_* except mtx_init and cnd_* except cnd_init are always reported

Due to the possibly static storage of the variables of type mtx_t and cnd_t used in a function, which causes proving that a variable is initialized much harder, all uses of initialized thread sychronization variables are always reported

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.14,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R22.14,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.15

Aliases

MC3.R22.15, MC3R2.R22.15, MC3A4.R22.15

Summary

Thread synchronization objects and thread-specific storage pointers shall not be destroyed until after all threads accessing them have terminated. (See page 29 of MISRA-C-2012-Amendment-4 [57] , page 240 of MISRA-C-2023 [58] , page 240 of MISRA-C-2025 [59] .)

Description

Reports any use of objects of types mtx_t, cnd_t and tss_t that are destroyed while being accessed by threads

Imprecision

False positives are possible due to the undecidability of the rule

Reports uses of tss_delete, cnd_destroy and mtx_destroy on thread-specific storage pointers, condition variables and mutexes that are never accessed by any other thread after being destroyed.

Configuration

See generic service options.

Option statements
statements
-config=MC4.R22.15,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R22.15,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.16

Aliases

MC3.R22.16, MC3R2.R22.16, MC3A4.R22.16

Summary

All mutex objects locked by a thread shall be explicitly unlocked by the same thread. (See page 29 of MISRA-C-2012-Amendment-4 [57] , page 241 of MISRA-C-2023 [58] , page 241 of MISRA-C-2025 [59] .)

Imprecision

Invocations of mtx_unlock are always reported

Mutex objects that are locked by a thread and follow the mandated unlocking policy (i.e., all such objects are unlocked before thread termination) are reported as cautions

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.16,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R22.16,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.17

Aliases

MC3.R22.17, MC3R2.R22.17, MC3A4.R22.17

Summary

No thread shall unlock a mutex or call cnd_wait() or cnd_timedwait() for a mutex it has not locked before. (See page 34 of MISRA-C-2012-Amendment-4 [57] , page 242 of MISRA-C-2023 [58] , page 242 of MISRA-C-2025 [59] .)

Description

Reports any call to the mtx_unlock, cnd_wait and cnd_timedwait Standard Library functions

Imprecision

False positives are reported due to the undecidability of the rule

All invocations of mtx_unlock, cnd_wait and cnd_timedwait on a mutex that is locked by the same thread are reported

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.17,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R22.17,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.18

Aliases

MC3.R22.18, MC3R2.R22.18, MC3A4.R22.18

Summary

Non-recursive mutexes shall not be recursively locked. (See page 35 of MISRA-C-2012-Amendment-4 [57] , page 243 of MISRA-C-2023 [58] , page 243 of MISRA-C-2025 [59] .)

Imprecision

False positives are reported due to the undecidability of the rule

All invocations of mtx_init where the type of the mutex to be initialized does not contain mtx_recursive can possibly be locked recursively, thereby violating the rule

Configuration

See generic service options.

Option calls
calls
-config=MC4.R22.18,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MC4.R22.18,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.19

Aliases

MC3.R22.19, MC3R2.R22.19, MC3A4.R22.19

Summary

A condition variable shall be associated with at most one mutex object. (See page 36 of MISRA-C-2012-Amendment-4 [57] , page 244 of MISRA-C-2023 [58] , page 244 of MISRA-C-2025 [59] .)

Description

All the function calls to mtx_wait and mtx_timedwait are reported as sources of the association of multiple distict mutexes to the same condition variable. The multiplicity of an association between a condition variable and a mutex is given by the syntactic presence of function calls and whether the address of an argument to such functions is fixed or unknown. The conditions for reporting are as follows:

  • a violation if multiple distinct mutexes with known addresses, and possibly other mutexes with unknown addresses, are associated to the same condition variable with a known address

  • a caution if a condition variable with a known address is associated to multiple mutexes with unknown addresses

  • a caution if a condition variable has an unknown address; such caution report will also contain areas for mutexes that are associated to other (known or unknown) condition variables, with duplicate mutexes occurrences removed

  • a caution if the address of the cnd_wait or cnd_timedwait function is taken

Imprecision

False positives are reported due to the undecidability of the rule

Condition variables with unknown addresses and mutexes with unknown addresses will be reported invariably as cautions, even if they may not give rise to the association of multiple mutexes to the same condition variable during program execution. Taking the address of the cnd_wait and cnd_timedwait may not give rise to a violation of the rule, but is always reported

Configuration

See generic service options.

Option declarations
declarations
-config=MC4.R22.19,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option statements
statements
-config=MC4.R22.19,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R22.19,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R22.20

Aliases

MC3.R22.20, MC3R2.R22.20, MC3A4.R22.20

Summary

Thread-specific storage pointers shall be created before being accessed. (See page 36 of MISRA-C-2012-Amendment-4 [57] , page 245 of MISRA-C-2023 [58] , page 245 of MISRA-C-2025 [59] .)

Imprecision

False positives are reported due to undecidability

Any use of variables of type tss_t with any level of indirection, except when used in a call to tss_create are reported, since they are potentially accessed before being created

Configuration

See generic service options.

Option statements
statements
-config=MC4.R22.20,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC4.R22.20,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC4.R23.1

Aliases

MC3.R23.1, MC3R2.R23.1, MC3A4.R23.1, MC3A3.R23.1

Summary

A generic selection should only be expanded from a macro. (See page 35 of MISRA-C-2012-Amendment-3 [55] , page 246 of MISRA-C-2023 [58] , page 246 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R23.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R23.2

Aliases

MC3.R23.2, MC3R2.R23.2, MC3A4.R23.2, MC3A3.R23.2

Summary

A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression. (See page 36 of MISRA-C-2012-Amendment-3 [55] , page 247 of MISRA-C-2023 [58] , page 247 of MISRA-C-2025 [59] .)

Description

Expressions with side effects must not be used in the controlling expression for calls to the _Generic operator.

Configuration

See generic service options.

Option effects
effects
-config=MC4.R23.2,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC4.R23.3

Aliases

MC3.R23.3, MC3R2.R23.3, MC3A4.R23.3, MC3A3.R23.3

Summary

A generic selection should contain at least one non-default association. (See page 37 of MISRA-C-2012-Amendment-3 [55] , page 248 of MISRA-C-2023 [58] , page 248 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R23.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R23.4

Aliases

MC3.R23.4, MC3R2.R23.4, MC3A4.R23.4, MC3A3.R23.4

Summary

A generic association shall list an appropriate type. (See page 38 of MISRA-C-2012-Amendment-3 [55] , page 249 of MISRA-C-2023 [58] , page 249 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R23.4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R23.5

Aliases

MC3.R23.5, MC3R2.R23.5, MC3A4.R23.5, MC3A3.R23.5

Summary

A generic selection should not depend on implicit pointer type conversion. (See page 40 of MISRA-C-2012-Amendment-3 [55] , page 251 of MISRA-C-2023 [58] , page 251 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R23.5,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R23.6

Aliases

MC3.R23.6, MC3R2.R23.6, MC3A4.R23.6, MC3A3.R23.6

Summary

The controlling expression of a generic selection shall have an essential type that matches its standard type. (See page 41 of MISRA-C-2012-Amendment-3 [55] , page 252 of MISRA-C-2023 [58] , page 252 of MISRA-C-2025 [59] .)

Description

Using an enumeration constant defined by a named enum as the controlling expression in a generic selection is reported as a violation iff the underlying type chosen to represent it, which is implementation-defined, is listed in the association types.

enum E {X,Y,Z};
enum E e = X;
// not a violation
_Generic(e, enum E: handle_enum);
// violation, assuming the underlying type chosen for E is unsigned int
_Generic(e, enum E: handle_enum, unsigned int: handle_uint);

Configuration

See generic service options.

Option statements
statements
-config=MC4.R23.6,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R23.7

Aliases

MC3.R23.7, MC3R2.R23.7, MC3A4.R23.7, MC3A3.R23.7

Summary

A generic selection that is expanded from a macro should evaluate its argument only once. (See page 43 of MISRA-C-2012-Amendment-3 [55] , page 254 of MISRA-C-2023 [58] , page 254 of MISRA-C-2025 [59] .)

Description

A generic selection expanded from a macro argument should contain no unbalanced association. In this context, an association is unbalanced if, for each macro argument, the count of expansions in each association is not the same. Macro arguments expanded to a compile time constant are not counted towards the determination of an unbalancement.

Configuration

See generic service options.

Option statements
statements
-config=MC4.R23.7,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MC4.R23.8

Aliases

MC3.R23.8, MC3R2.R23.8, MC3A4.R23.8, MC3A3.R23.8

Summary

A default association shall appear as either the first or the last association of a generic selection. (See page 44 of MISRA-C-2012-Amendment-3 [55] , page 255 of MISRA-C-2023 [58] , page 255 of MISRA-C-2025 [59] .)

Configuration

See generic service options.

Option statements
statements
-config=MC4.R23.8,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


MISRA C:2012 Additional Information

This section contains the following additional information related to the support of the coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 coding standard [45].

For all guidelines, the mapping between the MISRA C:2012 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Directive 1.1 maps to ECLAIR service MC3R0.D1.1,

  • MISRA C:2012 Rule 1.2 maps to ECLAIR service MC3R0.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3R0 synopsis: supported MISRA C:2012 guidelines

Id

Headline

Precision

MC3R0.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3R0.D2.1

All source files shall compile without any compilation errors

Process

MC3R0.D3.1

All code shall be traceable to documented requirements

Process

MC3R0.D4.1

Run-time failures shall be minimized

Process

MC3R0.D4.2

All usage of assembly language should be documented

Process

MC3R0.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3R0.D4.4

Sections of code should not be “commented out”

Heuristic

MC3R0.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3R0.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3R0.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3R0.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3R0.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3R0.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3R0.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3R0.D4.12

Dynamic memory allocation shall not be used

Process

MC3R0.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3R0.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3R0.R1.2

Language extensions should not be used

Safe

MC3R0.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3R0.R2.1

A project shall not contain unreachable code

Best-effort

MC3R0.R2.2

There shall be no dead code

Best-effort

MC3R0.R2.3

A project should not contain unused type declarations

Exact

MC3R0.R2.4

A project should not contain unused tag declarations

Exact

MC3R0.R2.5

A project should not contain unused macro declarations

Exact

MC3R0.R2.6

A function should not contain unused label declarations

Exact

MC3R0.R2.7

There should be no unused parameters in functions

Exact

MC3R0.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3R0.R3.2

Line-splicing shall not be used in // comments

Exact

MC3R0.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3R0.R4.2

Trigraphs should not be used

Exact

MC3R0.R5.1

External identifiers shall be distinct

Exact

MC3R0.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3R0.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3R0.R5.4

Macro identifiers shall be distinct

Exact

MC3R0.R5.5

Identifiers shall be distinct from macro names

Exact

MC3R0.R5.6

A typedef name shall be a unique identifier

Exact

MC3R0.R5.7

A tag name shall be a unique identifier

Exact

MC3R0.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3R0.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3R0.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3R0.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3R0.R7.1

Octal constants shall not be used

Exact

MC3R0.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3R0.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3R0.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3R0.R8.1

Types shall be explicitly specified

Exact

MC3R0.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3R0.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3R0.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3R0.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3R0.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3R0.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3R0.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3R0.R8.9

An object should be defined at block scope if its identifier only appears in a single function

Exact

MC3R0.R8.10

An inline function shall be declared with the static storage class

Exact

MC3R0.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3R0.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3R0.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3R0.R8.14

The restrict type qualifier shall not be used

Exact

MC3R0.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3R0.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3R0.R9.3

Arrays shall not be partially initialized

Exact

MC3R0.R9.4

An element of an object shall not be initialized more than once

Complete

MC3R0.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3R0.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3R0.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3R0.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3R0.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3R0.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3R0.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3R0.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3R0.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3R0.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3R0.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3R0.R11.3

A cast shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3R0.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3R0.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3R0.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3R0.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3R0.R11.8

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

Exact

MC3R0.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3R0.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3R0.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3R0.R12.3

The comma operator should not be used

Exact

MC3R0.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3R0.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3R0.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders

Safe

MC3R0.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3R0.R13.4

The result of an assignment operator should not be used

Exact

MC3R0.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3R0.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3R0.R14.1

A loop counter shall not have essentially floating type

Safe

MC3R0.R14.2

A for loop shall be well-formed

Safe

MC3R0.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3R0.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3R0.R15.1

The goto statement should not be used

Exact

MC3R0.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3R0.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3R0.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3R0.R15.5

A function should have a single point of exit at the end

Exact

MC3R0.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3R0.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3R0.R16.1

All switch statements shall be well-formed

Exact

MC3R0.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3R0.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3R0.R16.4

Every switch statement shall have a default label

Exact

MC3R0.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3R0.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3R0.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3R0.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3R0.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3R0.R17.3

A function shall not be declared implicitly

Exact

MC3R0.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3R0.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3R0.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3R0.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3R0.R17.8

A function parameter should not be modified

Precise

MC3R0.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3R0.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3R0.R18.3

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Safe

MC3R0.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3R0.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3R0.R18.6

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3R0.R18.7

Flexible array members shall not be declared

Exact

MC3R0.R18.8

Variable-length array types shall not be used

Exact

MC3R0.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3R0.R19.2

The union keyword should not be used

Exact

MC3R0.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3R0.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3R0.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3R0.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3R0.R20.5

#undef should not be used

Exact

MC3R0.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3R0.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3R0.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3R0.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3R0.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3R0.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3R0.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3R0.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3R0.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3R0.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3R0.R21.2

A reserved identifier or macro name shall not be declared

Exact

MC3R0.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3R0.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3R0.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3R0.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3R0.R21.7

The library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3R0.R21.8

The library functions abort, exit, getenv and system of <stdlib.h> shall not be used

Exact

MC3R0.R21.9

The library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3R0.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3R0.R21.11

The standard header file <tgmath.h> shall not be used

Exact

MC3R0.R21.12

The exception handling features of <fenv.h> should not be used

Exact

MC3R0.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3R0.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3R0.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3R0.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3R0.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3R0.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

Coverage of Undefined Behaviours for MISRA C:2012

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [45]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3R0.R1.3

Exact

2

MC3R0.R1.3

Exact

3

MC3R0.R20.10

Unsupported

3

3

3

MC3R0.R1.3

Exact

4

4

4

MC3R0.R1.3

Exact

5

6

6

MC3R0.R1.3

Exact

6

7

7

MC3R0.R1.3

Unsupported

5

MC3R0.R5.2

Exact

6

MC3R0.R17.3

Exact

8

7

8

8

MC3R0.R1.3

Exact

8

9

9

MC3R0.D4.12
MC3R0.R18.6
MC3R0.R21.3

Safe

9

MC3R0.D4.12
MC3R0.R18.6
MC3R0.R21.3

Safe

9

10

10

MC3R0.D4.12
MC3R0.R18.6
MC3R0.R21.3

Safe

10

11

11

MC3R0.R1.3

Safe

11

12

12

MC3R0.R1.3

Unsupported

12

13

13

MC3R0.R11.2
MC3R0.R11.3
MC3R0.R11.4
MC3R0.R11.5

Safe

13

14

14

MC3R0.R1.3

Unsupported

10

14

15

15

MC3R0.R5.6
MC3R0.R5.7
MC3R0.R8.3

Safe

15

MC3R0.D4.1
MC3R0.R10.3

Process

15

17

17

MC3R0.D4.1
MC3R0.R10.3

Process

16

18

18

MC3R0.D4.1
MC3R0.R10.3

Process

17

19

19

MC3R0.R9.1
MC3R0.R11.2
MC3R0.R11.3
MC3R0.R11.4
MC3R0.R11.5
MC3R0.R19.1

Process

16

18

20

20

MC3R0.R1.3

Exact

19

22

22

MC3R0.R1.3

Exact

17

20

23

23

MC3R0.R1.3

Exact

21

24

24

MC3R0.R11.1
MC3R0.R11.2
MC3R0.R11.4
MC3R0.R11.6

Safe

22

25

25

MC3R0.R11.2
MC3R0.R11.3
MC3R0.R11.5

Safe

27

23

26

26

MC3R0.R11.1

Safe

4

24

27

27

MC3R0.R1.3

Exact

25

28

28

MC3R0.R1.3

Exact

26

29

29

MC3R0.R1.3

Exact

27

30

30

MC3R0.R1.3

Exact

7

28

31

31

MC3R0.R5.1
MC3R0.R5.2
MC3R0.R5.3
MC3R0.R5.4
MC3R0.R5.5

Exact

29

32

32

MC3R0.R21.2

Exact

11

MC3R0.R1.3

Exact

12

30

33

33

MC3R0.R7.4
MC3R0.R11.4
MC3R0.R11.8

Safe

13

MC3R0.R1.3

Exact

14

MC3R0.R20.2

Exact

31

34

34

MC3R0.R20.2

Exact

18

32

35

35

MC3R0.R13.2
MC3R0.R13.3
MC3R0.R13.4

Safe

19

33

36

36

MC3R0.D4.1

Process

20

MC3R0.R11.3
MC3R0.R11.4
MC3R0.R11.5

Safe

34

37

37

MC3R0.R11.3
MC3R0.R11.4
MC3R0.R11.5

Safe

35

MC3R0.R1.3

Safe

21

MC3R0.R1.3

Exact

22

36

38

38

MC3R0.R8.2
MC3R0.R17.3

Safe

23

MC3R0.R8.2
MC3R0.R17.3

Safe

24

MC3R0.R5.6
MC3R0.R5.7
MC3R0.R8.3
MC3R0.R8.4
MC3R0.R8.5
MC3R0.R11.1
MC3R0.R21.2

Safe

25

MC3R0.R8.4
MC3R0.R8.5
MC3R0.R11.1
MC3R0.R21.2
MC3R0.R17.3

Safe

37

39

39

MC3R0.R8.4
MC3R0.R8.5
MC3R0.R11.1
MC3R0.R21.2

Safe

38

40

40

MC3R0.R8.2

Safe

39

41

41

MC3R0.R5.6
MC3R0.R5.7
MC3R0.R8.2
MC3R0.R8.3
MC3R0.R8.4
MC3R0.R8.5
MC3R0.R11.1
MC3R0.R21.2

Safe

26

40

43

43

MC3R0.D4.1

Process

28

MC3R0.R11.1

Exact

29

41

44

44

MC3R0.R11.1
MC3R0.R11.2
MC3R0.R11.6
MC3R0.R11.7

Exact

42

45

45

MC3R0.D4.1

Process

30

43

46

47

MC3R0.R18.1

Best-effort

44

47

48

MC3R0.R18.1

Best-effort

31

45

48

49

MC3R0.R18.2

Best-effort

46

49

50

MC3R0.R18.1

Best-effort

47

50

51

MC3R0.R1.3

Process

32

48

51

52

MC3R0.R12.2

Safe

49

52

53

MC3R0.R1.3

Unsupported

33

50

53

54

MC3R0.R18.3

Best-effort

34

51

54

55

MC3R0.R19.1

Best-effort

52

55

56

MC3R0.R1.3

Exact

53

56

57

MC3R0.R1.3

Exact

54

57

58

MC3R0.R1.3

Exact

55

58

59

MC3R0.R1.3

Unsupported

35

56

59

60

MC3R0.R1.3

Exact

36

57

60

61

MC3R0.R1.3

Exact

37

58

61

62

MC3R0.R1.3

Exact

38

MC3R0.R6.1

Exact

59

62

63

MC3R0.R18.7

Safe

60

63

64

MC3R0.R1.3

Exact

39

61

64

65

MC3R0.R11.4
MC3R0.R11.8
MC3R0.R19.2

Safe

40

62

65

66

MC3R0.R11.4
MC3R0.R11.8
MC3R0.R19.2

Safe

41

MC3R0.R9.1

Safe

63

66

67

MC3R0.R1.3

Exact

64

67

68

MC3R0.R1.3

Exact

65

68

69

MC3R0.R8.14

Safe

66

69

70

MC3R0.R8.14

Safe

67

70

71

MC3R0.R8.10

Safe

68

74

75

MC3R0.R1.3

Exact

69

75

76

MC3R0.R18.8

Safe

70

76

77

MC3R0.R18.8

Safe

71

77

78

MC3R0.R17.6

Safe

72

78

79

MC3R0.R1.3

Exact

73

79

80

MC3R0.R8.2
MC3R0.R11.1

Safe

74

80

81

MC3R0.R1.3

Unsupported

75

81

82

MC3R0.R1.3

Exact

42

MC3R0.R9.2

Safe

76

82

83

MC3R0.R9.2

Safe

77

83

84

MC3R0.R9.2

Safe

44

78

84

85

MC3R0.R8.6

Exact

79

85

86

MC3R0.R8.2

Safe

80

86

87

MC3R0.R1.3

Exact

45

81

87

88

MC3R0.R17.1

Safe

43

82

88

89

MC3R0.R17.4

Exact

46

83

89

90

MC3R0.R1.3

Exact

47

84

90

92

MC3R0.R1.3

Exact

48

85

91

93

MC3R0.R20.3

Exact

86

92

94

MC3R0.R1.3

Unsupported

49

MC3R0.R1.3

Exact

50

87

93

95

MC3R0.R20.6

Exact

51

88

94

96

MC3R0.R20.10

Safe

52

89

95

97

MC3R0.R20.10

Safe

53

90

96

98

MC3R0.R1.3

Exact

91

97

99

MC3R0.R1.3

Exact

92

98

100

MC3R0.R1.3

Exact

54

93

99

101

MC3R0.R21.1

Safe

55

94

100

102

MC3R0.R1.3

Safe

95

101

103

MC3R0.R1.3

Unsupported

56

MC3R0.R17.3
MC3R0.R20.1
MC3R0.R20.4
MC3R0.R21.2

Safe

96

102

104

MC3R0.R20.1

Safe

97

103

105

MC3R0.R20.1
MC3R0.R21.2

Safe

98

104

106

MC3R0.R20.4

Safe

57

MC3R0.R21.1
MC3R0.R21.2

Exact

99

105

107

MC3R0.R21.2

Safe

100

106

108

MC3R0.R21.1
MC3R0.R21.2

Safe

101

107

109

MC3R0.R21.1

Safe

60

102

108

110

MC3R0.D4.11

Best-effort

103

109

111

MC3R0.D4.11

Best-effort

61

MC3R0.R17.3
MC3R0.R21.2

Safe

62

104

110

112

MC3R0.R1.3

Safe

105

111

113

MC3R0.R1.3

Unsupported

106

112

114

MC3R0.R1.3

Exact

63

107

113

115

MC3R0.D4.11

Safe

58

MC3R0.R21.1

Safe

108

114

116

MC3R0.R1.3

Safe

109

115

117

MC3R0.R1.3

Safe

110

116

118

MC3R0.R21.12

Safe

111

117

119

MC3R0.R21.12

Safe

112

118

120

MC3R0.D4.11

Safe

90

MC3R0.R21.7

Safe

94

MC3R0.R1.3

Unsupported

113

119

121

MC3R0.R1.3

Unsupported

114

120

122

MC3R0.R1.3

Safe

115

121

123

MC3R0.R1.3

Safe

116

122

124

MC3R0.R21.1
MC3R0.R21.2

Safe

117

123

125

MC3R0.R1.3

Unsupported

64

MC3R0.R21.1
MC3R0.R21.2
MC3R0.R21.4

Safe

118

124

126

MC3R0.R21.1
MC3R0.R21.2
MC3R0.R21.4

Safe

65

119

125

127

MC3R0.R21.4

Safe

120

126

128

MC3R0.R21.4

Safe

66

121

127

129

MC3R0.R21.4

Safe

67

MC3R0.R21.4
MC3R0.R21.5

Safe

122

128

130

MC3R0.R21.5

Safe

123

129

131

MC3R0.R21.5

Safe

124

131

133

MC3R0.R21.5

Safe

68

MC3R0.R21.5

Safe

125

132

134

MC3R0.R21.5

Safe

69

126

133

135

MC3R0.R21.5

Safe

127

134

136

MC3R0.R21.5

Safe

128

136

138

MC3R0.R1.3

Safe

70

129

137

139

MC3R0.R17.1

Safe

71

MC3R0.R17.1
MC3R0.R21.1
MC3R0.R21.2

Safe

130

138

140

MC3R0.R17.1
MC3R0.R21.1
MC3R0.R21.2

Safe

75

MC3R0.R17.1

Safe

76

MC3R0.R17.1

Safe

131

139

141

MC3R0.R17.1

Safe

132

140

142

MC3R0.R17.1

Safe

73

MC3R0.R17.1

Safe

74

MC3R0.R17.1

Safe

133

141

143

MC3R0.R17.1

Safe

134

142

144

MC3R0.R17.1

Safe

72

135

143

145

MC3R0.R17.1

Safe

59

136

144

147

MC3R0.R1.3

Unsupported

137

145

148

MC3R0.R1.3

Exact

138

146

149

MC3R0.R21.6

Safe

139

147

150

MC3R0.R21.6

Safe

140

148

151

MC3R0.R21.6

Safe

77

141

149

152

MC3R0.R21.6

Safe

142

150

153

MC3R0.R21.6

Safe

78

143

151

154

MC3R0.R21.6

Safe

144

152

155

MC3R0.R21.6

Safe

79

MC3R0.R21.6

Safe

85

MC3R0.R21.6

Safe

145

153

156

MC3R0.R21.6

Safe

146

154

157

MC3R0.R21.6
MC3R0.R21.10

Safe

147

155

158

MC3R0.R21.6

Safe

148

156

159

MC3R0.R21.6

Safe

83

MC3R0.R21.6

Safe

84

MC3R0.R21.6

Safe

149

157

160

MC3R0.R21.6

Safe

82

MC3R0.R21.6

Safe

87

MC3R0.R21.6

Safe

150

158

161

MC3R0.R21.6

Safe

151

159

162

MC3R0.R21.6

Safe

152

160

163

MC3R0.R21.6

Safe

81

153

161

164

MC3R0.R21.6

Safe

97

MC3R0.R21.10

Safe

80

154

162

165

MC3R0.R21.6
MC3R0.R21.10

Safe

86

155

163

166

MC3R0.R21.6

Safe

89

156

165

168

MC3R0.R21.6

Safe

157

166

169

MC3R0.R21.6

Safe

158

167

170

MC3R0.R21.6

Safe

88

159

168

171

MC3R0.R21.6

Safe

160

169

172

MC3R0.R21.6

Safe

161

170

173

MC3R0.R21.6

Safe

162

171

174

MC3R0.R21.6

Safe

163

172

175

MC3R0.R21.6

Safe

164

173

176

MC3R0.R21.6

Safe

165

174

177

MC3R0.R21.6

Safe

166

175

178

MC3R0.R21.6

Safe

167

176

179

MC3R0.R21.3

Safe

91

168

177

180

MC3R0.R21.3

Safe

92

169

179

181

MC3R0.R21.3
MC3R0.R22.2

Safe

170

180

182

MC3R0.R21.3

Safe

171

181

183

MC3R0.R21.3

Safe

93

172

182

184

MC3R0.R21.8

Safe

173

183

185

MC3R0.R21.4

Safe

174

184

186

MC3R0.R1.3

Safe

175

186

188

MC3R0.R21.8

Safe

176

187

189

MC3R0.R21.9

Safe

177

188

190

MC3R0.R21.9

Safe

178

189

191

MC3R0.R21.9

Safe

95

179

190

192

MC3R0.R1.3

Unsupported

96

180

191

193

MC3R0.D4.11

Best-effort

181

192

194

MC3R0.D4.11

Best-effort

182

193

195

MC3R0.R1.3

Unsupported

183

194

196

MC3R0.D4.11

Unsupported

184

195

197

MC3R0.R21.11

Safe

185

196

198

MC3R0.R21.11

Safe

186

198

206

MC3R0.R21.6

Safe

187

199

207

MC3R0.D4.11

Unsupported

188

200

208

MC3R0.R1.3

Unsupported

189

201

209

MC3R0.D4.11

Best-effort

190

202

210

MC3R0.R1.3

Unsupported

191

203

211

MC3R0.R1.3

Unsupported

MISRA C:2012 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 coding standard [45].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3R0.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3R0.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3R0.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3R0.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3R0.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3R0.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3R0.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3R0.D4.6

Dir 4.7
Required

no violation report for MC3R0.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3R0.D4.8

Dir 4.9
Advisory

no violation report for MC3R0.D4.9

Dir 4.10
Required

no violation report for MC3R0.D4.10

Dir 4.11
Required

no violation report for MC3R0.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3R0.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3R0.D4.13

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3R0.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3R0.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table for MC is reported with the indicated precision.;
after: nothing to do

Rule 2.1
Required
Undecidable
System

no violation report for MC3R0.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3R0.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3R0.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3R0.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3R0.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R2.7

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3R0.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3R0.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3R0.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3R0.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3R0.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3R0.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3R0.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R6.2

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3R0.R7.4

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3R0.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3R0.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3R0.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3R0.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3R0.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3R0.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3R0.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3R0.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3R0.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3R0.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3R0.R8.14

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3R0.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3R0.R9.5

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3R0.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3R0.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3R0.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3R0.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3R0.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3R0.R11.9

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3R0.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R12.4

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3R0.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3R0.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3R0.R13.5

Rule 13.6
Mandatory
Decidable
Single T.U.

no violation report for MC3R0.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3R0.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3R0.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3R0.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3R0.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3R0.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3R0.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3R0.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3R0.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3R0.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3R0.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3R0.R17.4

Rule 17.5
Advisory
Undecidable
System

no violation report or caution report for MC3R0.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3R0.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3R0.R17.8

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3R0.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3R0.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3R0.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3R0.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3R0.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3R0.R18.8

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3R0.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3R0.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3R0.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.10

Rule 21.11
Required
Decidable
Single T.U.

no violation report for MC3R0.R21.11

Rule 21.12
Advisory
Decidable
Single T.U.

no violation report for MC3R0.R21.12

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3R0.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3R0.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3R0.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3R0.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3R0.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3R0.R22.6

MISRA C:2012 Amendment 1 Additional Information

This section contains the following additional information related to the support of the coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Amendment 1 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 Amendment 1 coding standard [46].

For all guidelines, the mapping between the MISRA C:2012 Amendment 1 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Amendment 1 Directive 1.1 maps to ECLAIR service MC3A1.D1.1,

  • MISRA C:2012 Amendment 1 Rule 1.2 maps to ECLAIR service MC3A1.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3A1 synopsis: supported MISRA C:2012 Amendment 1 guidelines

Id

Headline

Precision

MC3A1.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3A1.D2.1

All source files shall compile without any compilation errors

Process

MC3A1.D3.1

All code shall be traceable to documented requirements

Process

MC3A1.D4.1

Run-time failures shall be minimized

Process

MC3A1.D4.2

All usage of assembly language should be documented

Process

MC3A1.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3A1.D4.4

Sections of code should not be “commented out”

Heuristic

MC3A1.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3A1.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3A1.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3A1.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3A1.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3A1.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3A1.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3A1.D4.12

Dynamic memory allocation shall not be used

Process

MC3A1.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3A1.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3A1.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3A1.R1.2

Language extensions should not be used

Safe

MC3A1.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3A1.R2.1

A project shall not contain unreachable code

Best-effort

MC3A1.R2.2

There shall be no dead code

Best-effort

MC3A1.R2.3

A project should not contain unused type declarations

Exact

MC3A1.R2.4

A project should not contain unused tag declarations

Exact

MC3A1.R2.5

A project should not contain unused macro declarations

Exact

MC3A1.R2.6

A function should not contain unused label declarations

Exact

MC3A1.R2.7

There should be no unused parameters in functions

Exact

MC3A1.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3A1.R3.2

Line-splicing shall not be used in // comments

Exact

MC3A1.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3A1.R4.2

Trigraphs should not be used

Exact

MC3A1.R5.1

External identifiers shall be distinct

Exact

MC3A1.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3A1.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3A1.R5.4

Macro identifiers shall be distinct

Exact

MC3A1.R5.5

Identifiers shall be distinct from macro names

Exact

MC3A1.R5.6

A typedef name shall be a unique identifier

Exact

MC3A1.R5.7

A tag name shall be a unique identifier

Exact

MC3A1.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3A1.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3A1.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3A1.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3A1.R7.1

Octal constants shall not be used

Exact

MC3A1.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3A1.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3A1.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3A1.R8.1

Types shall be explicitly specified

Exact

MC3A1.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3A1.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3A1.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3A1.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3A1.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3A1.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3A1.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3A1.R8.9

An object should be defined at block scope if its identifier only appears in a single function

Exact

MC3A1.R8.10

An inline function shall be declared with the static storage class

Exact

MC3A1.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3A1.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3A1.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3A1.R8.14

The restrict type qualifier shall not be used

Exact

MC3A1.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3A1.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3A1.R9.3

Arrays shall not be partially initialized

Exact

MC3A1.R9.4

An element of an object shall not be initialized more than once

Complete

MC3A1.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3A1.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3A1.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3A1.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3A1.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3A1.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3A1.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3A1.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3A1.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3A1.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3A1.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3A1.R11.3

A cast shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3A1.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3A1.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3A1.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3A1.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3A1.R11.8

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

Exact

MC3A1.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3A1.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3A1.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3A1.R12.3

The comma operator should not be used

Exact

MC3A1.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3A1.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3A1.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3A1.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders

Safe

MC3A1.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3A1.R13.4

The result of an assignment operator should not be used

Exact

MC3A1.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3A1.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3A1.R14.1

A loop counter shall not have essentially floating type

Safe

MC3A1.R14.2

A for loop shall be well-formed

Safe

MC3A1.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3A1.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3A1.R15.1

The goto statement should not be used

Exact

MC3A1.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3A1.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3A1.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3A1.R15.5

A function should have a single point of exit at the end

Exact

MC3A1.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3A1.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3A1.R16.1

All switch statements shall be well-formed

Exact

MC3A1.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3A1.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3A1.R16.4

Every switch statement shall have a default label

Exact

MC3A1.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3A1.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3A1.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3A1.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3A1.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3A1.R17.3

A function shall not be declared implicitly

Exact

MC3A1.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3A1.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3A1.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3A1.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3A1.R17.8

A function parameter should not be modified

Precise

MC3A1.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3A1.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3A1.R18.3

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Safe

MC3A1.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3A1.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3A1.R18.6

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3A1.R18.7

Flexible array members shall not be declared

Exact

MC3A1.R18.8

Variable-length array types shall not be used

Exact

MC3A1.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3A1.R19.2

The union keyword should not be used

Exact

MC3A1.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3A1.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3A1.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3A1.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3A1.R20.5

#undef should not be used

Exact

MC3A1.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3A1.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3A1.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3A1.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3A1.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3A1.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3A1.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3A1.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3A1.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3A1.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3A1.R21.2

A reserved identifier or macro name shall not be declared

Exact

MC3A1.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3A1.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3A1.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3A1.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3A1.R21.7

The library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3A1.R21.8

The library functions abort, exit and system of <stdlib.h> shall not be used

Exact

MC3A1.R21.9

The library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3A1.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3A1.R21.11

The standard header file <tgmath.h> shall not be used

Exact

MC3A1.R21.12

The exception handling features of <fenv.h> should not be used

Exact

MC3A1.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3A1.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3A1.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3A1.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3A1.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3A1.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3A1.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3A1.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3A1.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3A1.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3A1.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3A1.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3A1.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3A1.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3A1.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3A1.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3A1.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3A1.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

Coverage of Undefined Behaviours for MISRA C:2012 Amendment 1

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [46]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3A1.R1.3

Exact

2

MC3A1.R1.3

Exact

3

MC3A1.R20.10

Unsupported

3

3

3

MC3A1.R1.3

Exact

4

4

4

MC3A1.R1.3

Exact

5

6

6

MC3A1.R1.3

Exact

6

7

7

MC3A1.R1.3

Unsupported

5

MC3A1.R5.2

Exact

6

MC3A1.R17.3

Exact

8

7

8

8

MC3A1.R1.3

Exact

8

9

9

MC3A1.D4.12
MC3A1.R18.6
MC3A1.R21.3

Safe

9

MC3A1.D4.12
MC3A1.R18.6
MC3A1.R21.3

Safe

9

10

10

MC3A1.D4.12
MC3A1.R18.6
MC3A1.R21.3

Safe

10

11

11

MC3A1.R1.3

Safe

11

12

12

MC3A1.R1.3

Unsupported

12

13

13

MC3A1.R11.2
MC3A1.R11.3
MC3A1.R11.4
MC3A1.R11.5

Safe

13

14

14

MC3A1.R1.3

Unsupported

10

14

15

15

MC3A1.R5.6
MC3A1.R5.7
MC3A1.R8.3

Safe

15

MC3A1.D4.1
MC3A1.R10.3

Process

15

17

17

MC3A1.D4.1
MC3A1.R10.3

Process

16

18

18

MC3A1.D4.1
MC3A1.R10.3

Process

17

19

19

MC3A1.R9.1
MC3A1.R11.2
MC3A1.R11.3
MC3A1.R11.4
MC3A1.R11.5
MC3A1.R19.1

Process

16

18

20

20

MC3A1.R1.3

Exact

19

22

22

MC3A1.R1.3

Exact

17

20

23

23

MC3A1.R1.3

Exact

21

24

24

MC3A1.R11.1
MC3A1.R11.2
MC3A1.R11.4
MC3A1.R11.6

Safe

22

25

25

MC3A1.R11.2
MC3A1.R11.3
MC3A1.R11.5

Safe

27

23

26

26

MC3A1.R11.1

Safe

4

24

27

27

MC3A1.R1.3

Exact

25

28

28

MC3A1.R1.3

Exact

26

29

29

MC3A1.R1.3

Exact

27

30

30

MC3A1.R1.3

Exact

7

28

31

31

MC3A1.R5.1
MC3A1.R5.2
MC3A1.R5.3
MC3A1.R5.4
MC3A1.R5.5

Exact

29

32

32

MC3A1.R21.2

Exact

11

MC3A1.R1.3

Exact

12

30

33

33

MC3A1.R7.4
MC3A1.R11.4
MC3A1.R11.8

Safe

13

MC3A1.R1.3

Exact

14

MC3A1.R20.2

Exact

31

34

34

MC3A1.R20.2

Exact

18

32

35

35

MC3A1.R13.2
MC3A1.R13.3
MC3A1.R13.4

Safe

19

33

36

36

MC3A1.D4.1

Process

20

MC3A1.R11.3
MC3A1.R11.4
MC3A1.R11.5

Safe

34

37

37

MC3A1.R11.3
MC3A1.R11.4
MC3A1.R11.5

Safe

35

MC3A1.R1.3

Safe

21

MC3A1.R1.3

Exact

22

36

38

38

MC3A1.R8.2
MC3A1.R17.3

Safe

23

MC3A1.R8.2
MC3A1.R17.3

Safe

24

MC3A1.R5.6
MC3A1.R5.7
MC3A1.R8.3
MC3A1.R8.4
MC3A1.R8.5
MC3A1.R11.1
MC3A1.R21.2

Safe

25

MC3A1.R8.4
MC3A1.R8.5
MC3A1.R11.1
MC3A1.R21.2
MC3A1.R17.3

Safe

37

39

39

MC3A1.R8.4
MC3A1.R8.5
MC3A1.R11.1
MC3A1.R21.2

Safe

38

40

40

MC3A1.R8.2

Safe

39

41

41

MC3A1.R5.6
MC3A1.R5.7
MC3A1.R8.2
MC3A1.R8.3
MC3A1.R8.4
MC3A1.R8.5
MC3A1.R11.1
MC3A1.R21.2

Safe

26

40

43

43

MC3A1.D4.1

Process

28

MC3A1.R11.1

Exact

29

41

44

44

MC3A1.R11.1
MC3A1.R11.2
MC3A1.R11.6
MC3A1.R11.7

Exact

42

45

45

MC3A1.D4.1

Process

30

43

46

47

MC3A1.R18.1

Best-effort

44

47

48

MC3A1.R18.1

Best-effort

31

45

48

49

MC3A1.R18.2

Best-effort

46

49

50

MC3A1.R18.1

Best-effort

47

50

51

MC3A1.R1.3

Process

32

48

51

52

MC3A1.R12.2

Safe

49

52

53

MC3A1.R1.3

Unsupported

33

50

53

54

MC3A1.R18.3

Best-effort

34

51

54

55

MC3A1.R19.1

Best-effort

52

55

56

MC3A1.R1.3

Exact

53

56

57

MC3A1.R1.3

Exact

54

57

58

MC3A1.R1.3

Exact

55

58

59

MC3A1.R1.3

Unsupported

35

56

59

60

MC3A1.R1.3

Exact

36

57

60

61

MC3A1.R1.3

Exact

37

58

61

62

MC3A1.R1.3

Exact

38

MC3A1.R6.1

Exact

59

62

63

MC3A1.R18.7

Safe

60

63

64

MC3A1.R1.3

Exact

39

61

64

65

MC3A1.R11.4
MC3A1.R11.8
MC3A1.R19.2

Safe

40

62

65

66

MC3A1.R11.4
MC3A1.R11.8
MC3A1.R19.2

Safe

41

MC3A1.R9.1

Safe

63

66

67

MC3A1.R1.3

Exact

64

67

68

MC3A1.R1.3

Exact

65

68

69

MC3A1.R8.14

Safe

66

69

70

MC3A1.R8.14

Safe

67

70

71

MC3A1.R8.10

Safe

68

74

75

MC3A1.R1.3

Exact

69

75

76

MC3A1.R18.8

Safe

70

76

77

MC3A1.R18.8

Safe

71

77

78

MC3A1.R17.6

Safe

72

78

79

MC3A1.R1.3

Exact

73

79

80

MC3A1.R8.2
MC3A1.R11.1

Safe

74

80

81

MC3A1.R1.3

Unsupported

75

81

82

MC3A1.R1.3

Exact

42

MC3A1.R9.2

Safe

76

82

83

MC3A1.R9.2

Safe

77

83

84

MC3A1.R9.2

Safe

44

78

84

85

MC3A1.R8.6

Exact

79

85

86

MC3A1.R8.2

Safe

80

86

87

MC3A1.R1.3

Exact

45

81

87

88

MC3A1.R17.1

Safe

43

82

88

89

MC3A1.R17.4

Exact

46

83

89

90

MC3A1.R1.3

Exact

47

84

90

92

MC3A1.R1.3

Exact

48

85

91

93

MC3A1.R20.3

Exact

86

92

94

MC3A1.R1.3

Unsupported

49

MC3A1.R1.3

Exact

50

87

93

95

MC3A1.R20.6

Exact

51

88

94

96

MC3A1.R20.10

Safe

52

89

95

97

MC3A1.R20.10

Safe

53

90

96

98

MC3A1.R1.3

Exact

91

97

99

MC3A1.R1.3

Exact

92

98

100

MC3A1.R1.3

Exact

54

93

99

101

MC3A1.R21.1

Safe

55

94

100

102

MC3A1.R1.3

Safe

95

101

103

MC3A1.R1.3

Unsupported

56

MC3A1.R17.3
MC3A1.R20.1
MC3A1.R20.4
MC3A1.R21.2

Safe

96

102

104

MC3A1.R20.1

Safe

97

103

105

MC3A1.R20.1
MC3A1.R21.2

Safe

98

104

106

MC3A1.R20.4

Safe

57

MC3A1.R21.1
MC3A1.R21.2

Exact

99

105

107

MC3A1.R21.2

Safe

100

106

108

MC3A1.R21.1
MC3A1.R21.2

Safe

101

107

109

MC3A1.R21.1

Safe

60

102

108

110

MC3A1.D4.11

Best-effort

103

109

111

MC3A1.D4.11

Best-effort

61

MC3A1.R17.3
MC3A1.R21.2

Safe

62

104

110

112

MC3A1.R1.3

Safe

105

111

113

MC3A1.R1.3

Unsupported

106

112

114

MC3A1.R1.3

Exact

63

107

113

115

MC3A1.D4.11

Safe

58

MC3A1.R21.1

Safe

108

114

116

MC3A1.R1.3

Safe

109

115

117

MC3A1.R1.3

Safe

110

116

118

MC3A1.R21.12

Safe

111

117

119

MC3A1.R21.12

Safe

112

118

120

MC3A1.D4.11

Safe

90

MC3A1.R21.7

Safe

94

MC3A1.R1.3

Unsupported

113

119

121

MC3A1.R1.3

Unsupported

114

120

122

MC3A1.R1.3

Safe

115

121

123

MC3A1.R1.3

Safe

116

122

124

MC3A1.R21.1
MC3A1.R21.2

Safe

117

123

125

MC3A1.R1.3

Unsupported

64

MC3A1.R21.1
MC3A1.R21.2
MC3A1.R21.4

Safe

118

124

126

MC3A1.R21.1
MC3A1.R21.2
MC3A1.R21.4

Safe

65

119

125

127

MC3A1.R21.4

Safe

120

126

128

MC3A1.R21.4

Safe

66

121

127

129

MC3A1.R21.4

Safe

67

MC3A1.R21.4
MC3A1.R21.5

Safe

122

128

130

MC3A1.R21.5

Safe

123

129

131

MC3A1.R21.5

Safe

124

131

133

MC3A1.R21.5

Safe

68

MC3A1.R21.5

Safe

125

132

134

MC3A1.R21.5

Safe

69

126

133

135

MC3A1.R21.5

Safe

127

134

136

MC3A1.R21.5

Safe

128

136

138

MC3A1.R1.3

Safe

70

129

137

139

MC3A1.R17.1

Safe

71

MC3A1.R17.1
MC3A1.R21.1
MC3A1.R21.2

Safe

130

138

140

MC3A1.R17.1
MC3A1.R21.1
MC3A1.R21.2

Safe

75

MC3A1.R17.1

Safe

76

MC3A1.R17.1

Safe

131

139

141

MC3A1.R17.1

Safe

132

140

142

MC3A1.R17.1

Safe

73

MC3A1.R17.1

Safe

74

MC3A1.R17.1

Safe

133

141

143

MC3A1.R17.1

Safe

134

142

144

MC3A1.R17.1

Safe

72

135

143

145

MC3A1.R17.1

Safe

59

136

144

147

MC3A1.R1.3

Unsupported

137

145

148

MC3A1.R1.3

Exact

138

146

149

MC3A1.R21.6

Safe

139

147

150

MC3A1.R21.6

Safe

140

148

151

MC3A1.R21.6

Safe

77

141

149

152

MC3A1.R21.6

Safe

142

150

153

MC3A1.R21.6

Safe

78

143

151

154

MC3A1.R21.6

Safe

144

152

155

MC3A1.R21.6

Safe

79

MC3A1.R21.6

Safe

85

MC3A1.R21.6

Safe

145

153

156

MC3A1.R21.6

Safe

146

154

157

MC3A1.R21.6
MC3A1.R21.10

Safe

147

155

158

MC3A1.R21.6

Safe

148

156

159

MC3A1.R21.6

Safe

83

MC3A1.R21.6

Safe

84

MC3A1.R21.6

Safe

149

157

160

MC3A1.R21.6

Safe

82

MC3A1.R21.6

Safe

87

MC3A1.R21.6

Safe

150

158

161

MC3A1.R21.6

Safe

151

159

162

MC3A1.R21.6

Safe

152

160

163

MC3A1.R21.6

Safe

81

153

161

164

MC3A1.R21.6

Safe

97

MC3A1.R21.10

Safe

80

154

162

165

MC3A1.R21.6
MC3A1.R21.10

Safe

86

155

163

166

MC3A1.R21.6

Safe

89

156

165

168

MC3A1.R21.6

Safe

157

166

169

MC3A1.R21.6

Safe

158

167

170

MC3A1.R21.6

Safe

88

159

168

171

MC3A1.R21.6

Safe

160

169

172

MC3A1.R21.6

Safe

161

170

173

MC3A1.R21.6

Safe

162

171

174

MC3A1.R21.6

Safe

163

172

175

MC3A1.R21.6

Safe

164

173

176

MC3A1.R21.6

Safe

165

174

177

MC3A1.R21.6

Safe

166

175

178

MC3A1.R21.6

Safe

167

176

179

MC3A1.R21.3

Safe

91

168

177

180

MC3A1.R21.3

Safe

92

169

179

181

MC3A1.R21.3
MC3A1.R22.2

Safe

170

180

182

MC3A1.R21.3

Safe

171

181

183

MC3A1.R21.3

Safe

93

172

182

184

MC3A1.R21.8

Safe

173

183

185

MC3A1.R21.4

Safe

174

184

186

MC3A1.R1.3

Safe

175

186

188

MC3A1.R21.8

Safe

176

187

189

MC3A1.R21.9

Safe

177

188

190

MC3A1.R21.9

Safe

178

189

191

MC3A1.R21.9

Safe

95

179

190

192

MC3A1.R1.3

Unsupported

96

180

191

193

MC3A1.D4.11

Best-effort

181

192

194

MC3A1.D4.11

Best-effort

182

193

195

MC3A1.R1.3

Unsupported

183

194

196

MC3A1.D4.11

Unsupported

184

195

197

MC3A1.R21.11

Safe

185

196

198

MC3A1.R21.11

Safe

186

198

206

MC3A1.R21.6

Safe

187

199

207

MC3A1.D4.11

Unsupported

188

200

208

MC3A1.R1.3

Unsupported

189

201

209

MC3A1.D4.11

Best-effort

190

202

210

MC3A1.R1.3

Unsupported

191

203

211

MC3A1.R1.3

Unsupported

MISRA C:2012 Amendment 1 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 Amendment 1 coding standard [46].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 Amendment 1 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3A1.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3A1.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3A1.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3A1.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3A1.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3A1.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3A1.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3A1.D4.6

Dir 4.7
Required

no violation report for MC3A1.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3A1.D4.8

Dir 4.9
Advisory

no violation report for MC3A1.D4.9

Dir 4.10
Required

no violation report for MC3A1.D4.10

Dir 4.11
Required

no violation report for MC3A1.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3A1.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3A1.D4.13

Dir 4.14
Required

no violation report for MC3A1.D4.14

after: ensure that the external program input is adequately sanitized before use

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3A1.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3A1.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table for MC is reported with the indicated precision.;
after: nothing to do

Rule 2.1
Required
Undecidable
System

no violation report for MC3A1.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3A1.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3A1.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3A1.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3A1.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R2.7

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3A1.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3A1.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3A1.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3A1.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3A1.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3A1.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3A1.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R6.2

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A1.R7.4

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3A1.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3A1.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3A1.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3A1.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3A1.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3A1.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3A1.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3A1.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3A1.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3A1.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3A1.R8.14

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A1.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3A1.R9.5

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3A1.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3A1.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3A1.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3A1.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3A1.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3A1.R11.9

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3A1.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3A1.R12.5

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3A1.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3A1.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3A1.R13.5

Rule 13.6
Mandatory
Decidable
Single T.U.

no violation report for MC3A1.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3A1.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3A1.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3A1.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3A1.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3A1.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3A1.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3A1.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3A1.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3A1.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3A1.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3A1.R17.4

Rule 17.5
Advisory
Undecidable
System

no violation report or caution report for MC3A1.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3A1.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3A1.R17.8

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3A1.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3A1.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3A1.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3A1.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3A1.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3A1.R18.8

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3A1.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3A1.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.10

Rule 21.11
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.11

Rule 21.12
Advisory
Decidable
Single T.U.

no violation report for MC3A1.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3A1.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3A1.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R21.20

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3A1.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3A1.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3A1.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3A1.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3A1.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3A1.R22.10

MISRA C:2012 Technical Corrigendum 1 Additional Information

This section contains the following additional information related to the support of the coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Technical Corrigendum 1 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 Technical Corrigendum 1 coding standard [48].

For all guidelines, the mapping between the MISRA C:2012 Technical Corrigendum 1 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Technical Corrigendum 1 Directive 1.1 maps to ECLAIR service MC3C1.D1.1,

  • MISRA C:2012 Technical Corrigendum 1 Rule 1.2 maps to ECLAIR service MC3C1.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3C1 synopsis: supported MISRA C:2012 Technical Corrigendum 1 guidelines

Id

Headline

Precision

MC3C1.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3C1.D2.1

All source files shall compile without any compilation errors

Process

MC3C1.D3.1

All code shall be traceable to documented requirements

Process

MC3C1.D4.1

Run-time failures shall be minimized

Process

MC3C1.D4.2

All usage of assembly language should be documented

Process

MC3C1.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3C1.D4.4

Sections of code should not be “commented out”

Heuristic

MC3C1.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3C1.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3C1.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3C1.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3C1.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3C1.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3C1.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3C1.D4.12

Dynamic memory allocation shall not be used

Process

MC3C1.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3C1.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3C1.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3C1.R1.2

Language extensions should not be used

Safe

MC3C1.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3C1.R2.1

A project shall not contain unreachable code

Best-effort

MC3C1.R2.2

There shall be no dead code

Best-effort

MC3C1.R2.3

A project should not contain unused type declarations

Exact

MC3C1.R2.4

A project should not contain unused tag declarations

Exact

MC3C1.R2.5

A project should not contain unused macro declarations

Exact

MC3C1.R2.6

A function should not contain unused label declarations

Exact

MC3C1.R2.7

There should be no unused parameters in functions

Exact

MC3C1.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3C1.R3.2

Line-splicing shall not be used in // comments

Exact

MC3C1.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3C1.R4.2

Trigraphs should not be used

Exact

MC3C1.R5.1

External identifiers shall be distinct

Exact

MC3C1.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3C1.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3C1.R5.4

Macro identifiers shall be distinct

Exact

MC3C1.R5.5

Identifiers shall be distinct from macro names

Exact

MC3C1.R5.6

A typedef name shall be a unique identifier

Exact

MC3C1.R5.7

A tag name shall be a unique identifier

Exact

MC3C1.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3C1.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3C1.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3C1.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3C1.R7.1

Octal constants shall not be used

Exact

MC3C1.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3C1.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3C1.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3C1.R8.1

Types shall be explicitly specified

Exact

MC3C1.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3C1.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3C1.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3C1.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3C1.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3C1.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3C1.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3C1.R8.9

An object should be defined at block scope if its identifier only appears in a single function

Exact

MC3C1.R8.10

An inline function shall be declared with the static storage class

Exact

MC3C1.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3C1.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3C1.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3C1.R8.14

The restrict type qualifier shall not be used

Exact

MC3C1.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3C1.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3C1.R9.3

Arrays shall not be partially initialized

Exact

MC3C1.R9.4

An element of an object shall not be initialized more than once

Complete

MC3C1.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3C1.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3C1.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3C1.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3C1.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3C1.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3C1.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3C1.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3C1.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3C1.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3C1.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3C1.R11.3

A cast shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3C1.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3C1.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3C1.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3C1.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3C1.R11.8

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

Exact

MC3C1.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3C1.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3C1.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3C1.R12.3

The comma operator should not be used

Exact

MC3C1.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3C1.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3C1.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3C1.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders

Safe

MC3C1.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3C1.R13.4

The result of an assignment operator should not be used

Exact

MC3C1.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3C1.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3C1.R14.1

A loop counter shall not have essentially floating type

Safe

MC3C1.R14.2

A for loop shall be well-formed

Safe

MC3C1.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3C1.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3C1.R15.1

The goto statement should not be used

Exact

MC3C1.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3C1.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3C1.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3C1.R15.5

A function should have a single point of exit at the end

Exact

MC3C1.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3C1.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3C1.R16.1

All switch statements shall be well-formed

Exact

MC3C1.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3C1.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3C1.R16.4

Every switch statement shall have a default label

Exact

MC3C1.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3C1.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3C1.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3C1.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3C1.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3C1.R17.3

A function shall not be declared implicitly

Exact

MC3C1.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3C1.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3C1.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3C1.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3C1.R17.8

A function parameter should not be modified

Precise

MC3C1.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3C1.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3C1.R18.3

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Safe

MC3C1.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3C1.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3C1.R18.6

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3C1.R18.7

Flexible array members shall not be declared

Exact

MC3C1.R18.8

Variable-length array types shall not be used

Exact

MC3C1.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3C1.R19.2

The union keyword should not be used

Exact

MC3C1.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3C1.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3C1.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3C1.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3C1.R20.5

#undef should not be used

Exact

MC3C1.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3C1.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3C1.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3C1.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3C1.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3C1.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3C1.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3C1.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3C1.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3C1.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3C1.R21.2

A reserved identifier or reserved macro name shall not be declared

Exact

MC3C1.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3C1.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3C1.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3C1.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3C1.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3C1.R21.8

The Standard Library functions abort, exit and system of <stdlib.h> shall not be used

Exact

MC3C1.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3C1.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3C1.R21.11

The standard header file <tgmath.h> shall not be used

Exact

MC3C1.R21.12

The exception handling features of <fenv.h> should not be used

Exact

MC3C1.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3C1.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3C1.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3C1.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3C1.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3C1.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3C1.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3C1.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3C1.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3C1.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3C1.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3C1.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3C1.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3C1.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3C1.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3C1.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3C1.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3C1.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

Coverage of Undefined Behaviours for MISRA C:2012 Technical Corrigendum 1

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [48]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3C1.R1.3

Exact

2

MC3C1.R1.3

Exact

3

MC3C1.R20.10

Unsupported

3

3

3

MC3C1.R1.3

Exact

4

4

4

MC3C1.R1.3

Exact

5

6

6

MC3C1.R1.3

Exact

6

7

7

MC3C1.R1.3

Unsupported

5

MC3C1.R5.2

Exact

6

MC3C1.R17.3

Exact

8

7

8

8

MC3C1.R1.3

Exact

8

9

9

MC3C1.D4.12
MC3C1.R18.6
MC3C1.R21.3

Safe

9

MC3C1.D4.12
MC3C1.R18.6
MC3C1.R21.3

Safe

9

10

10

MC3C1.D4.12
MC3C1.R18.6
MC3C1.R21.3

Safe

10

11

11

MC3C1.R1.3

Safe

11

12

12

MC3C1.R1.3

Unsupported

12

13

13

MC3C1.R11.2
MC3C1.R11.3
MC3C1.R11.4
MC3C1.R11.5

Safe

13

14

14

MC3C1.R1.3

Unsupported

10

14

15

15

MC3C1.R5.6
MC3C1.R5.7
MC3C1.R8.3

Safe

15

MC3C1.D4.1
MC3C1.R10.3

Process

15

17

17

MC3C1.D4.1
MC3C1.R10.3

Process

16

18

18

MC3C1.D4.1
MC3C1.R10.3

Process

17

19

19

MC3C1.R9.1
MC3C1.R11.2
MC3C1.R11.3
MC3C1.R11.4
MC3C1.R11.5
MC3C1.R19.1

Process

16

18

20

20

MC3C1.R1.3

Exact

19

22

22

MC3C1.R1.3

Exact

17

20

23

23

MC3C1.R1.3

Exact

21

24

24

MC3C1.R11.1
MC3C1.R11.2
MC3C1.R11.4
MC3C1.R11.6

Safe

22

25

25

MC3C1.R11.2
MC3C1.R11.3
MC3C1.R11.5

Safe

27

23

26

26

MC3C1.R11.1

Safe

4

24

27

27

MC3C1.R1.3

Exact

25

28

28

MC3C1.R1.3

Exact

26

29

29

MC3C1.R1.3

Exact

27

30

30

MC3C1.R1.3

Exact

7

28

31

31

MC3C1.R5.1
MC3C1.R5.2
MC3C1.R5.3
MC3C1.R5.4
MC3C1.R5.5

Exact

29

32

32

MC3C1.R21.2

Exact

11

MC3C1.R1.3

Exact

12

30

33

33

MC3C1.R7.4
MC3C1.R11.4
MC3C1.R11.8

Safe

13

MC3C1.R1.3

Exact

14

MC3C1.R20.2

Exact

31

34

34

MC3C1.R20.2

Exact

18

32

35

35

MC3C1.R13.2
MC3C1.R13.3
MC3C1.R13.4

Safe

19

33

36

36

MC3C1.D4.1

Process

20

MC3C1.R11.3
MC3C1.R11.4
MC3C1.R11.5

Safe

34

37

37

MC3C1.R11.3
MC3C1.R11.4
MC3C1.R11.5

Safe

35

MC3C1.R1.3

Safe

21

MC3C1.R1.3

Exact

22

36

38

38

MC3C1.R8.2
MC3C1.R17.3

Safe

23

MC3C1.R8.2
MC3C1.R17.3

Safe

24

MC3C1.R5.6
MC3C1.R5.7
MC3C1.R8.3
MC3C1.R8.4
MC3C1.R8.5
MC3C1.R11.1
MC3C1.R21.2

Safe

25

MC3C1.R8.4
MC3C1.R8.5
MC3C1.R11.1
MC3C1.R21.2
MC3C1.R17.3

Safe

37

39

39

MC3C1.R8.4
MC3C1.R8.5
MC3C1.R11.1
MC3C1.R21.2

Safe

38

40

40

MC3C1.R8.2

Safe

39

41

41

MC3C1.R5.6
MC3C1.R5.7
MC3C1.R8.2
MC3C1.R8.3
MC3C1.R8.4
MC3C1.R8.5
MC3C1.R11.1
MC3C1.R21.2

Safe

26

40

43

43

MC3C1.D4.1

Process

28

MC3C1.R11.1

Exact

29

41

44

44

MC3C1.R11.1
MC3C1.R11.2
MC3C1.R11.6
MC3C1.R11.7

Exact

42

45

45

MC3C1.D4.1

Process

30

43

46

47

MC3C1.R18.1

Best-effort

44

47

48

MC3C1.R18.1

Best-effort

31

45

48

49

MC3C1.R18.2

Best-effort

46

49

50

MC3C1.R18.1

Best-effort

47

50

51

MC3C1.R1.3

Process

32

48

51

52

MC3C1.R12.2

Safe

49

52

53

MC3C1.R1.3

Unsupported

33

50

53

54

MC3C1.R18.3

Best-effort

34

51

54

55

MC3C1.R19.1

Best-effort

52

55

56

MC3C1.R1.3

Exact

53

56

57

MC3C1.R1.3

Exact

54

57

58

MC3C1.R1.3

Exact

55

58

59

MC3C1.R1.3

Unsupported

35

56

59

60

MC3C1.R1.3

Exact

36

57

60

61

MC3C1.R1.3

Exact

37

58

61

62

MC3C1.R1.3

Exact

38

MC3C1.R6.1

Exact

59

62

63

MC3C1.R18.7

Safe

60

63

64

MC3C1.R1.3

Exact

39

61

64

65

MC3C1.R11.4
MC3C1.R11.8
MC3C1.R19.2

Safe

40

62

65

66

MC3C1.R11.4
MC3C1.R11.8
MC3C1.R19.2

Safe

41

MC3C1.R9.1

Safe

63

66

67

MC3C1.R1.3

Exact

64

67

68

MC3C1.R1.3

Exact

65

68

69

MC3C1.R8.14

Safe

66

69

70

MC3C1.R8.14

Safe

67

70

71

MC3C1.R8.10

Safe

68

74

75

MC3C1.R1.3

Exact

69

75

76

MC3C1.R18.8

Safe

70

76

77

MC3C1.R18.8

Safe

71

77

78

MC3C1.R17.6

Safe

72

78

79

MC3C1.R1.3

Exact

73

79

80

MC3C1.R8.2
MC3C1.R11.1

Safe

74

80

81

MC3C1.R1.3

Unsupported

75

81

82

MC3C1.R1.3

Exact

42

MC3C1.R9.2

Safe

76

82

83

MC3C1.R9.2

Safe

77

83

84

MC3C1.R9.2

Safe

44

78

84

85

MC3C1.R8.6

Exact

79

85

86

MC3C1.R8.2

Safe

80

86

87

MC3C1.R1.3

Exact

45

81

87

88

MC3C1.R17.1

Safe

43

82

88

89

MC3C1.R17.4

Exact

46

83

89

90

MC3C1.R1.3

Exact

47

84

90

92

MC3C1.R1.3

Exact

48

85

91

93

MC3C1.R20.3

Exact

86

92

94

MC3C1.R1.3

Unsupported

49

MC3C1.R1.3

Exact

50

87

93

95

MC3C1.R20.6

Exact

51

88

94

96

MC3C1.R20.10

Safe

52

89

95

97

MC3C1.R20.10

Safe

53

90

96

98

MC3C1.R1.3

Exact

91

97

99

MC3C1.R1.3

Exact

92

98

100

MC3C1.R1.3

Exact

54

93

99

101

MC3C1.R21.1

Safe

55

94

100

102

MC3C1.R1.3

Safe

95

101

103

MC3C1.R1.3

Unsupported

56

MC3C1.R17.3
MC3C1.R20.1
MC3C1.R20.4
MC3C1.R21.2

Safe

96

102

104

MC3C1.R20.1

Safe

97

103

105

MC3C1.R20.1
MC3C1.R21.2

Safe

98

104

106

MC3C1.R20.4

Safe

57

MC3C1.R21.1
MC3C1.R21.2

Exact

99

105

107

MC3C1.R21.2

Safe

100

106

108

MC3C1.R21.1
MC3C1.R21.2

Safe

101

107

109

MC3C1.R21.1

Safe

60

102

108

110

MC3C1.D4.11

Best-effort

103

109

111

MC3C1.D4.11

Best-effort

61

MC3C1.R17.3
MC3C1.R21.2

Safe

62

104

110

112

MC3C1.R1.3

Safe

105

111

113

MC3C1.R1.3

Unsupported

106

112

114

MC3C1.R1.3

Exact

63

107

113

115

MC3C1.D4.11

Safe

58

MC3C1.R21.1

Safe

108

114

116

MC3C1.R1.3

Safe

109

115

117

MC3C1.R1.3

Safe

110

116

118

MC3C1.R21.12

Safe

111

117

119

MC3C1.R21.12

Safe

112

118

120

MC3C1.D4.11

Safe

90

MC3C1.R21.7

Safe

94

MC3C1.R1.3

Unsupported

113

119

121

MC3C1.R1.3

Unsupported

114

120

122

MC3C1.R1.3

Safe

115

121

123

MC3C1.R1.3

Safe

116

122

124

MC3C1.R21.1
MC3C1.R21.2

Safe

117

123

125

MC3C1.R1.3

Unsupported

64

MC3C1.R21.1
MC3C1.R21.2
MC3C1.R21.4

Safe

118

124

126

MC3C1.R21.1
MC3C1.R21.2
MC3C1.R21.4

Safe

65

119

125

127

MC3C1.R21.4

Safe

120

126

128

MC3C1.R21.4

Safe

66

121

127

129

MC3C1.R21.4

Safe

67

MC3C1.R21.4
MC3C1.R21.5

Safe

122

128

130

MC3C1.R21.5

Safe

123

129

131

MC3C1.R21.5

Safe

124

131

133

MC3C1.R21.5

Safe

68

MC3C1.R21.5

Safe

125

132

134

MC3C1.R21.5

Safe

69

126

133

135

MC3C1.R21.5

Safe

127

134

136

MC3C1.R21.5

Safe

128

136

138

MC3C1.R1.3

Safe

70

129

137

139

MC3C1.R17.1

Safe

71

MC3C1.R17.1
MC3C1.R21.1
MC3C1.R21.2

Safe

130

138

140

MC3C1.R17.1
MC3C1.R21.1
MC3C1.R21.2

Safe

75

MC3C1.R17.1

Safe

76

MC3C1.R17.1

Safe

131

139

141

MC3C1.R17.1

Safe

132

140

142

MC3C1.R17.1

Safe

73

MC3C1.R17.1

Safe

74

MC3C1.R17.1

Safe

133

141

143

MC3C1.R17.1

Safe

134

142

144

MC3C1.R17.1

Safe

72

135

143

145

MC3C1.R17.1

Safe

59

136

144

147

MC3C1.R1.3

Unsupported

137

145

148

MC3C1.R1.3

Exact

138

146

149

MC3C1.R21.6

Safe

139

147

150

MC3C1.R21.6

Safe

140

148

151

MC3C1.R21.6

Safe

77

141

149

152

MC3C1.R21.6

Safe

142

150

153

MC3C1.R21.6

Safe

78

143

151

154

MC3C1.R21.6

Safe

144

152

155

MC3C1.R21.6

Safe

79

MC3C1.R21.6

Safe

85

MC3C1.R21.6

Safe

145

153

156

MC3C1.R21.6

Safe

146

154

157

MC3C1.R21.6
MC3C1.R21.10

Safe

147

155

158

MC3C1.R21.6

Safe

148

156

159

MC3C1.R21.6

Safe

83

MC3C1.R21.6

Safe

84

MC3C1.R21.6

Safe

149

157

160

MC3C1.R21.6

Safe

82

MC3C1.R21.6

Safe

87

MC3C1.R21.6

Safe

150

158

161

MC3C1.R21.6

Safe

151

159

162

MC3C1.R21.6

Safe

152

160

163

MC3C1.R21.6

Safe

81

153

161

164

MC3C1.R21.6

Safe

97

MC3C1.R21.10

Safe

80

154

162

165

MC3C1.R21.6
MC3C1.R21.10

Safe

86

155

163

166

MC3C1.R21.6

Safe

89

156

165

168

MC3C1.R21.6

Safe

157

166

169

MC3C1.R21.6

Safe

158

167

170

MC3C1.R21.6

Safe

88

159

168

171

MC3C1.R21.6

Safe

160

169

172

MC3C1.R21.6

Safe

161

170

173

MC3C1.R21.6

Safe

162

171

174

MC3C1.R21.6

Safe

163

172

175

MC3C1.R21.6

Safe

164

173

176

MC3C1.R21.6

Safe

165

174

177

MC3C1.R21.6

Safe

166

175

178

MC3C1.R21.6

Safe

167

176

179

MC3C1.R21.3

Safe

91

168

177

180

MC3C1.R21.3

Safe

92

169

179

181

MC3C1.R21.3
MC3C1.R22.2

Safe

170

180

182

MC3C1.R21.3

Safe

171

181

183

MC3C1.R21.3

Safe

93

172

182

184

MC3C1.R21.8

Safe

173

183

185

MC3C1.R21.4

Safe

174

184

186

MC3C1.R1.3

Safe

175

186

188

MC3C1.R21.8

Safe

176

187

189

MC3C1.R21.9

Safe

177

188

190

MC3C1.R21.9

Safe

178

189

191

MC3C1.R21.9

Safe

95

179

190

192

MC3C1.R1.3

Unsupported

96

180

191

193

MC3C1.D4.11

Best-effort

181

192

194

MC3C1.D4.11

Best-effort

182

193

195

MC3C1.R1.3

Unsupported

183

194

196

MC3C1.D4.11

Unsupported

184

195

197

MC3C1.R21.11

Safe

185

196

198

MC3C1.R21.11

Safe

186

198

206

MC3C1.R21.6

Safe

187

199

207

MC3C1.D4.11

Unsupported

188

200

208

MC3C1.R1.3

Unsupported

189

201

209

MC3C1.D4.11

Best-effort

190

202

210

MC3C1.R1.3

Unsupported

191

203

211

MC3C1.R1.3

Unsupported

MISRA C:2012 Technical Corrigendum 1 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 Technical Corrigendum 1 coding standard [48].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 Technical Corrigendum 1 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3C1.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3C1.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3C1.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3C1.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3C1.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3C1.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3C1.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3C1.D4.6

Dir 4.7
Required

no violation report for MC3C1.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3C1.D4.8

Dir 4.9
Advisory

no violation report for MC3C1.D4.9

Dir 4.10
Required

no violation report for MC3C1.D4.10

Dir 4.11
Required

no violation report for MC3C1.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3C1.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3C1.D4.13

Dir 4.14
Required

no violation report for MC3C1.D4.14

after: ensure that the external program input is adequately sanitized before use

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3C1.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3C1.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table for MC is reported with the indicated precision.;
after: nothing to do

Rule 2.1
Required
Undecidable
System

no violation report for MC3C1.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3C1.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3C1.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3C1.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3C1.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R2.7

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3C1.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3C1.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3C1.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3C1.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3C1.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3C1.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3C1.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R6.2

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3C1.R7.4

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3C1.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3C1.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3C1.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3C1.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3C1.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3C1.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3C1.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3C1.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3C1.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3C1.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3C1.R8.14

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3C1.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3C1.R9.5

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3C1.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3C1.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3C1.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3C1.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3C1.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3C1.R11.9

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3C1.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3C1.R12.5

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3C1.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3C1.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3C1.R13.5

Rule 13.6
Mandatory
Decidable
Single T.U.

no violation report for MC3C1.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3C1.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3C1.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3C1.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3C1.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3C1.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3C1.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3C1.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3C1.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3C1.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3C1.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3C1.R17.4

Rule 17.5
Advisory
Undecidable
System

no violation report or caution report for MC3C1.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3C1.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3C1.R17.8

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3C1.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3C1.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3C1.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3C1.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3C1.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3C1.R18.8

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3C1.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3C1.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.10

Rule 21.11
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.11

Rule 21.12
Advisory
Decidable
Single T.U.

no violation report for MC3C1.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3C1.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3C1.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R21.20

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3C1.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3C1.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3C1.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3C1.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3C1.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3C1.R22.10

MISRA C:2012 Revision 1 Additional Information

This section contains the following additional information related to the support of the coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Revision 1 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 Revision 1 coding standard [51].

For all guidelines, the mapping between the MISRA C:2012 Revision 1 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Revision 1 Directive 1.1 maps to ECLAIR service MC3R1.D1.1,

  • MISRA C:2012 Revision 1 Rule 1.2 maps to ECLAIR service MC3R1.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3R1 synopsis: supported MISRA C:2012 Revision 1 guidelines

Id

Headline

Precision

MC3R1.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3R1.D2.1

All source files shall compile without any compilation errors

Process

MC3R1.D3.1

All code shall be traceable to documented requirements

Process

MC3R1.D4.1

Run-time failures shall be minimized

Process

MC3R1.D4.2

All usage of assembly language should be documented

Process

MC3R1.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3R1.D4.4

Sections of code should not be “commented out”

Heuristic

MC3R1.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3R1.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3R1.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3R1.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3R1.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3R1.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3R1.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3R1.D4.12

Dynamic memory allocation shall not be used

Process

MC3R1.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3R1.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3R1.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3R1.R1.2

Language extensions should not be used

Safe

MC3R1.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3R1.R2.1

A project shall not contain unreachable code

Best-effort

MC3R1.R2.2

There shall be no dead code

Best-effort

MC3R1.R2.3

A project should not contain unused type declarations

Exact

MC3R1.R2.4

A project should not contain unused tag declarations

Exact

MC3R1.R2.5

A project should not contain unused macro declarations

Exact

MC3R1.R2.6

A function should not contain unused label declarations

Exact

MC3R1.R2.7

There should be no unused parameters in functions

Exact

MC3R1.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3R1.R3.2

Line-splicing shall not be used in // comments

Exact

MC3R1.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3R1.R4.2

Trigraphs should not be used

Exact

MC3R1.R5.1

External identifiers shall be distinct

Exact

MC3R1.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3R1.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3R1.R5.4

Macro identifiers shall be distinct

Exact

MC3R1.R5.5

Identifiers shall be distinct from macro names

Exact

MC3R1.R5.6

A typedef name shall be a unique identifier

Exact

MC3R1.R5.7

A tag name shall be a unique identifier

Exact

MC3R1.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3R1.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3R1.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3R1.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3R1.R7.1

Octal constants shall not be used

Exact

MC3R1.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3R1.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3R1.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3R1.R8.1

Types shall be explicitly specified

Exact

MC3R1.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3R1.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3R1.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3R1.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3R1.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3R1.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3R1.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3R1.R8.9

An object should be defined at block scope if its identifier only appears in a single function

Exact

MC3R1.R8.10

An inline function shall be declared with the static storage class

Exact

MC3R1.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3R1.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3R1.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3R1.R8.14

The restrict type qualifier shall not be used

Exact

MC3R1.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3R1.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3R1.R9.3

Arrays shall not be partially initialized

Exact

MC3R1.R9.4

An element of an object shall not be initialized more than once

Complete

MC3R1.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3R1.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3R1.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3R1.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3R1.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3R1.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3R1.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3R1.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3R1.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3R1.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3R1.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3R1.R11.3

A cast shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3R1.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3R1.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3R1.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3R1.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3R1.R11.8

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

Exact

MC3R1.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3R1.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3R1.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3R1.R12.3

The comma operator should not be used

Exact

MC3R1.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3R1.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3R1.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3R1.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders

Safe

MC3R1.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3R1.R13.4

The result of an assignment operator should not be used

Exact

MC3R1.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3R1.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3R1.R14.1

A loop counter shall not have essentially floating type

Safe

MC3R1.R14.2

A for loop shall be well-formed

Safe

MC3R1.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3R1.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3R1.R15.1

The goto statement should not be used

Exact

MC3R1.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3R1.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3R1.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3R1.R15.5

A function should have a single point of exit at the end

Exact

MC3R1.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3R1.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3R1.R16.1

All switch statements shall be well-formed

Exact

MC3R1.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3R1.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3R1.R16.4

Every switch statement shall have a default label

Exact

MC3R1.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3R1.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3R1.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3R1.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3R1.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3R1.R17.3

A function shall not be declared implicitly

Exact

MC3R1.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3R1.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3R1.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3R1.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3R1.R17.8

A function parameter should not be modified

Precise

MC3R1.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3R1.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3R1.R18.3

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Safe

MC3R1.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3R1.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3R1.R18.6

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3R1.R18.7

Flexible array members shall not be declared

Exact

MC3R1.R18.8

Variable-length array types shall not be used

Exact

MC3R1.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3R1.R19.2

The union keyword should not be used

Exact

MC3R1.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3R1.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3R1.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3R1.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3R1.R20.5

#undef should not be used

Exact

MC3R1.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3R1.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3R1.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3R1.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3R1.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3R1.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3R1.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3R1.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3R1.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3R1.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3R1.R21.2

A reserved identifier or reserved macro name shall not be declared

Exact

MC3R1.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3R1.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3R1.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3R1.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3R1.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3R1.R21.8

The Standard Library functions abort, exit and system of <stdlib.h> shall not be used

Exact

MC3R1.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3R1.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3R1.R21.11

The standard header file <tgmath.h> shall not be used

Exact

MC3R1.R21.12

The exception handling features of <fenv.h> should not be used

Exact

MC3R1.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3R1.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3R1.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3R1.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3R1.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3R1.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3R1.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3R1.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3R1.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3R1.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3R1.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3R1.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3R1.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3R1.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3R1.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3R1.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3R1.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3R1.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

Coverage of Undefined Behaviours for MISRA C:2012 Revision 1

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [51]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3R1.R1.3

Exact

2

MC3R1.R1.3

Exact

3

MC3R1.R20.10

Unsupported

3

3

3

MC3R1.R1.3

Exact

4

4

4

MC3R1.R1.3

Exact

5

6

6

MC3R1.R1.3

Exact

6

7

7

MC3R1.R1.3

Unsupported

5

MC3R1.R5.2

Exact

6

MC3R1.R17.3

Exact

8

7

8

8

MC3R1.R1.3

Exact

8

9

9

MC3R1.D4.12
MC3R1.R18.6
MC3R1.R21.3

Safe

9

MC3R1.D4.12
MC3R1.R18.6
MC3R1.R21.3

Safe

9

10

10

MC3R1.D4.12
MC3R1.R18.6
MC3R1.R21.3

Safe

10

11

11

MC3R1.R1.3

Safe

11

12

12

MC3R1.R1.3

Unsupported

12

13

13

MC3R1.R11.2
MC3R1.R11.3
MC3R1.R11.4
MC3R1.R11.5

Safe

13

14

14

MC3R1.R1.3

Unsupported

10

14

15

15

MC3R1.R5.6
MC3R1.R5.7
MC3R1.R8.3

Safe

15

MC3R1.D4.1
MC3R1.R10.3

Process

15

17

17

MC3R1.D4.1
MC3R1.R10.3

Process

16

18

18

MC3R1.D4.1
MC3R1.R10.3

Process

17

19

19

MC3R1.R9.1
MC3R1.R11.2
MC3R1.R11.3
MC3R1.R11.4
MC3R1.R11.5
MC3R1.R19.1

Process

16

18

20

20

MC3R1.R1.3

Exact

19

22

22

MC3R1.R1.3

Exact

17

20

23

23

MC3R1.R1.3

Exact

21

24

24

MC3R1.R11.1
MC3R1.R11.2
MC3R1.R11.4
MC3R1.R11.6

Safe

22

25

25

MC3R1.R11.2
MC3R1.R11.3
MC3R1.R11.5

Safe

27

23

26

26

MC3R1.R11.1

Safe

4

24

27

27

MC3R1.R1.3

Exact

25

28

28

MC3R1.R1.3

Exact

26

29

29

MC3R1.R1.3

Exact

27

30

30

MC3R1.R1.3

Exact

7

28

31

31

MC3R1.R5.1
MC3R1.R5.2
MC3R1.R5.3
MC3R1.R5.4
MC3R1.R5.5

Exact

29

32

32

MC3R1.R21.2

Exact

11

MC3R1.R1.3

Exact

12

30

33

33

MC3R1.R7.4
MC3R1.R11.4
MC3R1.R11.8

Safe

13

MC3R1.R1.3

Exact

14

MC3R1.R20.2

Exact

31

34

34

MC3R1.R20.2

Exact

18

32

35

35

MC3R1.R13.2
MC3R1.R13.3
MC3R1.R13.4

Safe

19

33

36

36

MC3R1.D4.1

Process

20

MC3R1.R11.3
MC3R1.R11.4
MC3R1.R11.5

Safe

34

37

37

MC3R1.R11.3
MC3R1.R11.4
MC3R1.R11.5

Safe

35

MC3R1.R1.3

Safe

21

MC3R1.R1.3

Exact

22

36

38

38

MC3R1.R8.2
MC3R1.R17.3

Safe

23

MC3R1.R8.2
MC3R1.R17.3

Safe

24

MC3R1.R5.6
MC3R1.R5.7
MC3R1.R8.3
MC3R1.R8.4
MC3R1.R8.5
MC3R1.R11.1
MC3R1.R21.2

Safe

25

MC3R1.R8.4
MC3R1.R8.5
MC3R1.R11.1
MC3R1.R21.2
MC3R1.R17.3

Safe

37

39

39

MC3R1.R8.4
MC3R1.R8.5
MC3R1.R11.1
MC3R1.R21.2

Safe

38

40

40

MC3R1.R8.2

Safe

39

41

41

MC3R1.R5.6
MC3R1.R5.7
MC3R1.R8.2
MC3R1.R8.3
MC3R1.R8.4
MC3R1.R8.5
MC3R1.R11.1
MC3R1.R21.2

Safe

26

40

43

43

MC3R1.D4.1

Process

28

MC3R1.R11.1

Exact

29

41

44

44

MC3R1.R11.1
MC3R1.R11.2
MC3R1.R11.6
MC3R1.R11.7

Exact

42

45

45

MC3R1.D4.1

Process

30

43

46

47

MC3R1.R18.1

Best-effort

44

47

48

MC3R1.R18.1

Best-effort

31

45

48

49

MC3R1.R18.2

Best-effort

46

49

50

MC3R1.R18.1

Best-effort

47

50

51

MC3R1.R1.3

Process

32

48

51

52

MC3R1.R12.2

Safe

49

52

53

MC3R1.R1.3

Unsupported

33

50

53

54

MC3R1.R18.3

Best-effort

34

51

54

55

MC3R1.R19.1

Best-effort

52

55

56

MC3R1.R1.3

Exact

53

56

57

MC3R1.R1.3

Exact

54

57

58

MC3R1.R1.3

Exact

55

58

59

MC3R1.R1.3

Unsupported

35

56

59

60

MC3R1.R1.3

Exact

36

57

60

61

MC3R1.R1.3

Exact

37

58

61

62

MC3R1.R1.3

Exact

38

MC3R1.R6.1

Exact

59

62

63

MC3R1.R18.7

Safe

60

63

64

MC3R1.R1.3

Exact

39

61

64

65

MC3R1.R11.4
MC3R1.R11.8
MC3R1.R19.2

Safe

40

62

65

66

MC3R1.R11.4
MC3R1.R11.8
MC3R1.R19.2

Safe

41

MC3R1.R9.1

Safe

63

66

67

MC3R1.R1.3

Exact

64

67

68

MC3R1.R1.3

Exact

65

68

69

MC3R1.R8.14

Safe

66

69

70

MC3R1.R8.14

Safe

67

70

71

MC3R1.R8.10

Safe

68

74

75

MC3R1.R1.3

Exact

69

75

76

MC3R1.R18.8

Safe

70

76

77

MC3R1.R18.8

Safe

71

77

78

MC3R1.R17.6

Safe

72

78

79

MC3R1.R1.3

Exact

73

79

80

MC3R1.R8.2
MC3R1.R11.1

Safe

74

80

81

MC3R1.R1.3

Unsupported

75

81

82

MC3R1.R1.3

Exact

42

MC3R1.R9.2

Safe

76

82

83

MC3R1.R9.2

Safe

77

83

84

MC3R1.R9.2

Safe

44

78

84

85

MC3R1.R8.6

Exact

79

85

86

MC3R1.R8.2

Safe

80

86

87

MC3R1.R1.3

Exact

45

81

87

88

MC3R1.R17.1

Safe

43

82

88

89

MC3R1.R17.4

Exact

46

83

89

90

MC3R1.R1.3

Exact

47

84

90

92

MC3R1.R1.3

Exact

48

85

91

93

MC3R1.R20.3

Exact

86

92

94

MC3R1.R1.3

Unsupported

49

MC3R1.R1.3

Exact

50

87

93

95

MC3R1.R20.6

Exact

51

88

94

96

MC3R1.R20.10

Safe

52

89

95

97

MC3R1.R20.10

Safe

53

90

96

98

MC3R1.R1.3

Exact

91

97

99

MC3R1.R1.3

Exact

92

98

100

MC3R1.R1.3

Exact

54

93

99

101

MC3R1.R21.1

Safe

55

94

100

102

MC3R1.R1.3

Safe

95

101

103

MC3R1.R1.3

Unsupported

56

MC3R1.R17.3
MC3R1.R20.1
MC3R1.R20.4
MC3R1.R21.2

Safe

96

102

104

MC3R1.R20.1

Safe

97

103

105

MC3R1.R20.1
MC3R1.R21.2

Safe

98

104

106

MC3R1.R20.4

Safe

57

MC3R1.R21.1
MC3R1.R21.2

Exact

99

105

107

MC3R1.R21.2

Safe

100

106

108

MC3R1.R21.1
MC3R1.R21.2

Safe

101

107

109

MC3R1.R21.1

Safe

60

102

108

110

MC3R1.D4.11

Best-effort

103

109

111

MC3R1.D4.11

Best-effort

61

MC3R1.R17.3
MC3R1.R21.2

Safe

62

104

110

112

MC3R1.R1.3

Safe

105

111

113

MC3R1.R1.3

Unsupported

106

112

114

MC3R1.R1.3

Exact

63

107

113

115

MC3R1.D4.11

Safe

58

MC3R1.R21.1

Safe

108

114

116

MC3R1.R1.3

Safe

109

115

117

MC3R1.R1.3

Safe

110

116

118

MC3R1.R21.12

Safe

111

117

119

MC3R1.R21.12

Safe

112

118

120

MC3R1.D4.11

Safe

90

MC3R1.R21.7

Safe

94

MC3R1.R1.3

Unsupported

113

119

121

MC3R1.R1.3

Unsupported

114

120

122

MC3R1.R1.3

Safe

115

121

123

MC3R1.R1.3

Safe

116

122

124

MC3R1.R21.1
MC3R1.R21.2

Safe

117

123

125

MC3R1.R1.3

Unsupported

64

MC3R1.R21.1
MC3R1.R21.2
MC3R1.R21.4

Safe

118

124

126

MC3R1.R21.1
MC3R1.R21.2
MC3R1.R21.4

Safe

65

119

125

127

MC3R1.R21.4

Safe

120

126

128

MC3R1.R21.4

Safe

66

121

127

129

MC3R1.R21.4

Safe

67

MC3R1.R21.4
MC3R1.R21.5

Safe

122

128

130

MC3R1.R21.5

Safe

123

129

131

MC3R1.R21.5

Safe

124

131

133

MC3R1.R21.5

Safe

68

MC3R1.R21.5

Safe

125

132

134

MC3R1.R21.5

Safe

69

126

133

135

MC3R1.R21.5

Safe

127

134

136

MC3R1.R21.5

Safe

128

136

138

MC3R1.R1.3

Safe

70

129

137

139

MC3R1.R17.1

Safe

71

MC3R1.R17.1
MC3R1.R21.1
MC3R1.R21.2

Safe

130

138

140

MC3R1.R17.1
MC3R1.R21.1
MC3R1.R21.2

Safe

75

MC3R1.R17.1

Safe

76

MC3R1.R17.1

Safe

131

139

141

MC3R1.R17.1

Safe

132

140

142

MC3R1.R17.1

Safe

73

MC3R1.R17.1

Safe

74

MC3R1.R17.1

Safe

133

141

143

MC3R1.R17.1

Safe

134

142

144

MC3R1.R17.1

Safe

72

135

143

145

MC3R1.R17.1

Safe

59

136

144

147

MC3R1.R1.3

Unsupported

137

145

148

MC3R1.R1.3

Exact

138

146

149

MC3R1.R21.6

Safe

139

147

150

MC3R1.R21.6

Safe

140

148

151

MC3R1.R21.6

Safe

77

141

149

152

MC3R1.R21.6

Safe

142

150

153

MC3R1.R21.6

Safe

78

143

151

154

MC3R1.R21.6

Safe

144

152

155

MC3R1.R21.6

Safe

79

MC3R1.R21.6

Safe

85

MC3R1.R21.6

Safe

145

153

156

MC3R1.R21.6

Safe

146

154

157

MC3R1.R21.6
MC3R1.R21.10

Safe

147

155

158

MC3R1.R21.6

Safe

148

156

159

MC3R1.R21.6

Safe

83

MC3R1.R21.6

Safe

84

MC3R1.R21.6

Safe

149

157

160

MC3R1.R21.6

Safe

82

MC3R1.R21.6

Safe

87

MC3R1.R21.6

Safe

150

158

161

MC3R1.R21.6

Safe

151

159

162

MC3R1.R21.6

Safe

152

160

163

MC3R1.R21.6

Safe

81

153

161

164

MC3R1.R21.6

Safe

97

MC3R1.R21.10

Safe

80

154

162

165

MC3R1.R21.6
MC3R1.R21.10

Safe

86

155

163

166

MC3R1.R21.6

Safe

89

156

165

168

MC3R1.R21.6

Safe

157

166

169

MC3R1.R21.6

Safe

158

167

170

MC3R1.R21.6

Safe

88

159

168

171

MC3R1.R21.6

Safe

160

169

172

MC3R1.R21.6

Safe

161

170

173

MC3R1.R21.6

Safe

162

171

174

MC3R1.R21.6

Safe

163

172

175

MC3R1.R21.6

Safe

164

173

176

MC3R1.R21.6

Safe

165

174

177

MC3R1.R21.6

Safe

166

175

178

MC3R1.R21.6

Safe

167

176

179

MC3R1.R21.3

Safe

91

168

177

180

MC3R1.R21.3

Safe

92

169

179

181

MC3R1.R21.3
MC3R1.R22.2

Safe

170

180

182

MC3R1.R21.3

Safe

171

181

183

MC3R1.R21.3

Safe

93

172

182

184

MC3R1.R21.8

Safe

173

183

185

MC3R1.R21.4

Safe

174

184

186

MC3R1.R1.3

Safe

175

186

188

MC3R1.R21.8

Safe

176

187

189

MC3R1.R21.9

Safe

177

188

190

MC3R1.R21.9

Safe

178

189

191

MC3R1.R21.9

Safe

95

179

190

192

MC3R1.R1.3

Unsupported

96

180

191

193

MC3R1.D4.11

Best-effort

181

192

194

MC3R1.D4.11

Best-effort

182

193

195

MC3R1.R1.3

Unsupported

183

194

196

MC3R1.D4.11

Unsupported

184

195

197

MC3R1.R21.11

Safe

185

196

198

MC3R1.R21.11

Safe

186

198

206

MC3R1.R21.6

Safe

187

199

207

MC3R1.D4.11

Unsupported

188

200

208

MC3R1.R1.3

Unsupported

189

201

209

MC3R1.D4.11

Best-effort

190

202

210

MC3R1.R1.3

Unsupported

191

203

211

MC3R1.R1.3

Unsupported

MISRA C:2012 Revision 1 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 Revision 1 coding standard [51].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 Revision 1 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3R1.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3R1.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3R1.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3R1.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3R1.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3R1.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3R1.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3R1.D4.6

Dir 4.7
Required

no violation report for MC3R1.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3R1.D4.8

Dir 4.9
Advisory

no violation report for MC3R1.D4.9

Dir 4.10
Required

no violation report for MC3R1.D4.10

Dir 4.11
Required

no violation report for MC3R1.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3R1.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3R1.D4.13

Dir 4.14
Required

no violation report for MC3R1.D4.14

after: ensure that the external program input is adequately sanitized before use

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3R1.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3R1.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table for MC is reported with the indicated precision.;
after: nothing to do

Rule 2.1
Required
Undecidable
System

no violation report for MC3R1.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3R1.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3R1.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3R1.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3R1.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R2.7

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3R1.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3R1.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3R1.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3R1.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3R1.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3R1.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3R1.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R6.2

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3R1.R7.4

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3R1.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3R1.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3R1.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3R1.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3R1.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3R1.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3R1.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3R1.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3R1.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3R1.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3R1.R8.14

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3R1.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3R1.R9.5

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3R1.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3R1.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3R1.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3R1.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3R1.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3R1.R11.9

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3R1.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3R1.R12.5

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3R1.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3R1.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3R1.R13.5

Rule 13.6
Mandatory
Decidable
Single T.U.

no violation report for MC3R1.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3R1.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3R1.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3R1.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3R1.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3R1.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3R1.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3R1.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3R1.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3R1.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3R1.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3R1.R17.4

Rule 17.5
Advisory
Undecidable
System

no violation report or caution report for MC3R1.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3R1.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3R1.R17.8

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3R1.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3R1.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3R1.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3R1.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3R1.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3R1.R18.8

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3R1.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3R1.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.10

Rule 21.11
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.11

Rule 21.12
Advisory
Decidable
Single T.U.

no violation report for MC3R1.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3R1.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3R1.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R21.20

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3R1.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3R1.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3R1.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3R1.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3R1.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3R1.R22.10

MISRA C:2012 Amendment 2 Additional Information

This section contains the following additional information related to the support of the coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Amendment 2 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 Amendment 2 coding standard [52].

For all guidelines, the mapping between the MISRA C:2012 Amendment 2 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Amendment 2 Directive 1.1 maps to ECLAIR service MC3A2.D1.1,

  • MISRA C:2012 Amendment 2 Rule 1.2 maps to ECLAIR service MC3A2.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3A2 synopsis: supported MISRA C:2012 Amendment 2 guidelines

Id

Headline

Precision

MC3A2.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3A2.D2.1

All source files shall compile without any compilation errors

Process

MC3A2.D3.1

All code shall be traceable to documented requirements

Process

MC3A2.D4.1

Run-time failures shall be minimized

Process

MC3A2.D4.2

All usage of assembly language should be documented

Process

MC3A2.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3A2.D4.4

Sections of code should not be “commented out”

Heuristic

MC3A2.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3A2.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3A2.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3A2.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3A2.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3A2.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3A2.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3A2.D4.12

Dynamic memory allocation shall not be used

Process

MC3A2.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3A2.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3A2.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3A2.R1.2

Language extensions should not be used

Safe

MC3A2.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3A2.R1.4

Emergent language features shall not be used

Exact

MC3A2.R2.1

A project shall not contain unreachable code

Best-effort

MC3A2.R2.2

There shall be no dead code

Best-effort

MC3A2.R2.3

A project should not contain unused type declarations

Exact

MC3A2.R2.4

A project should not contain unused tag declarations

Exact

MC3A2.R2.5

A project should not contain unused macro declarations

Exact

MC3A2.R2.6

A function should not contain unused label declarations

Exact

MC3A2.R2.7

There should be no unused parameters in functions

Exact

MC3A2.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3A2.R3.2

Line-splicing shall not be used in // comments

Exact

MC3A2.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3A2.R4.2

Trigraphs should not be used

Exact

MC3A2.R5.1

External identifiers shall be distinct

Exact

MC3A2.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3A2.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3A2.R5.4

Macro identifiers shall be distinct

Exact

MC3A2.R5.5

Identifiers shall be distinct from macro names

Exact

MC3A2.R5.6

A typedef name shall be a unique identifier

Exact

MC3A2.R5.7

A tag name shall be a unique identifier

Exact

MC3A2.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3A2.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3A2.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3A2.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3A2.R7.1

Octal constants shall not be used

Exact

MC3A2.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3A2.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3A2.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3A2.R8.1

Types shall be explicitly specified

Exact

MC3A2.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3A2.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3A2.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3A2.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3A2.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3A2.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3A2.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3A2.R8.9

An object should be defined at block scope if its identifier only appears in a single function

Exact

MC3A2.R8.10

An inline function shall be declared with the static storage class

Exact

MC3A2.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3A2.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3A2.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3A2.R8.14

The restrict type qualifier shall not be used

Exact

MC3A2.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3A2.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3A2.R9.3

Arrays shall not be partially initialized

Exact

MC3A2.R9.4

An element of an object shall not be initialized more than once

Complete

MC3A2.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3A2.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3A2.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3A2.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3A2.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3A2.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3A2.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3A2.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3A2.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3A2.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3A2.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3A2.R11.3

A cast shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3A2.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3A2.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3A2.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3A2.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3A2.R11.8

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

Exact

MC3A2.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3A2.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3A2.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3A2.R12.3

The comma operator should not be used

Exact

MC3A2.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3A2.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3A2.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3A2.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders

Safe

MC3A2.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3A2.R13.4

The result of an assignment operator should not be used

Exact

MC3A2.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3A2.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3A2.R14.1

A loop counter shall not have essentially floating type

Safe

MC3A2.R14.2

A for loop shall be well-formed

Safe

MC3A2.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3A2.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3A2.R15.1

The goto statement should not be used

Exact

MC3A2.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3A2.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3A2.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3A2.R15.5

A function should have a single point of exit at the end

Exact

MC3A2.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3A2.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3A2.R16.1

All switch statements shall be well-formed

Exact

MC3A2.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3A2.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3A2.R16.4

Every switch statement shall have a default label

Exact

MC3A2.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3A2.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3A2.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3A2.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3A2.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3A2.R17.3

A function shall not be declared implicitly

Exact

MC3A2.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3A2.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3A2.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3A2.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3A2.R17.8

A function parameter should not be modified

Precise

MC3A2.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3A2.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3A2.R18.3

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Safe

MC3A2.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3A2.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3A2.R18.6

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3A2.R18.7

Flexible array members shall not be declared

Exact

MC3A2.R18.8

Variable-length array types shall not be used

Exact

MC3A2.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3A2.R19.2

The union keyword should not be used

Exact

MC3A2.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3A2.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3A2.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3A2.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3A2.R20.5

#undef should not be used

Exact

MC3A2.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3A2.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3A2.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3A2.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3A2.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3A2.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3A2.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3A2.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3A2.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3A2.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3A2.R21.2

A reserved identifier or reserved macro name shall not be declared

Exact

MC3A2.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3A2.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3A2.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3A2.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3A2.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3A2.R21.8

The Standard Library termination functions of <stdlib.h> shall not be used

Exact

MC3A2.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3A2.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3A2.R21.11

The standard header file <tgmath.h> shall not be used

Exact

MC3A2.R21.12

The exception handling features of <fenv.h> should not be used

Exact

MC3A2.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3A2.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3A2.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3A2.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3A2.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3A2.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3A2.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3A2.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3A2.R21.21

The Standard Library function system of <stdlib.h> shall not be used

Exact

MC3A2.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3A2.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3A2.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3A2.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3A2.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3A2.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3A2.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3A2.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3A2.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3A2.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

Coverage of Undefined Behaviours for MISRA C:2012 Amendment 2

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [52]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3A2.R1.3

Exact

2

MC3A2.R1.3

Exact

3

MC3A2.R20.10

Unsupported

3

3

3

MC3A2.R1.3

Exact

4

4

4

MC3A2.R1.3

Exact

5

5

MC3A2.R1.3

Unsupported

5

6

6

MC3A2.R1.3

Exact

6

7

7

MC3A2.R1.3

Unsupported

5

MC3A2.R5.2

Exact

6

MC3A2.R17.3

Exact

8

7

8

8

MC3A2.R1.3

Exact

8

9

9

MC3A2.D4.12
MC3A2.R18.6
MC3A2.R21.3

Safe

9

MC3A2.D4.12
MC3A2.R18.6
MC3A2.R21.3

Safe

9

10

10

MC3A2.D4.12
MC3A2.R18.6
MC3A2.R21.3

Safe

10

11

11

MC3A2.R1.3

Safe

11

12

12

MC3A2.R1.3

Unsupported

12

13

13

MC3A2.R11.2
MC3A2.R11.3
MC3A2.R11.4
MC3A2.R11.5

Safe

13

14

14

MC3A2.R1.3

Unsupported

10

14

15

15

MC3A2.R5.6
MC3A2.R5.7
MC3A2.R8.3

Safe

15

MC3A2.D4.1
MC3A2.D4.14
MC3A2.R10.3

Process

16

16

MC3A2.R18.8

Safe

15

17

17

MC3A2.D4.1
MC3A2.D4.14
MC3A2.R10.3

Process

16

18

18

MC3A2.D4.1
MC3A2.D4.14
MC3A2.R10.3

Process

17

19

19

MC3A2.R9.1
MC3A2.R11.2
MC3A2.R11.3
MC3A2.R11.4
MC3A2.R11.5
MC3A2.R19.1

Process

16

18

20

20

MC3A2.R1.3

Exact

21

21

MC3A2.R1.3

Safe

19

22

22

MC3A2.R1.3

Exact

17

20

23

23

MC3A2.R1.3

Exact

21

24

24

MC3A2.R11.1
MC3A2.R11.2
MC3A2.R11.4
MC3A2.R11.6

Safe

22

25

25

MC3A2.R11.2
MC3A2.R11.3
MC3A2.R11.5

Safe

27

23

26

26

MC3A2.R11.1

Safe

4

24

27

27

MC3A2.R1.3

Exact

25

28

28

MC3A2.R1.3

Exact

26

29

29

MC3A2.R1.3

Exact

27

30

30

MC3A2.R1.3

Exact

7

28

31

31

MC3A2.R5.1
MC3A2.R5.2
MC3A2.R5.3
MC3A2.R5.4
MC3A2.R5.5

Exact

29

32

32

MC3A2.R21.2

Exact

11

MC3A2.R1.3

Exact

12

30

33

33

MC3A2.R7.4
MC3A2.R11.4
MC3A2.R11.8

Safe

13

MC3A2.R1.3

Exact

14

MC3A2.R20.2

Exact

31

34

34

MC3A2.R20.2

Exact

18

32

35

35

MC3A2.R13.2
MC3A2.R13.3
MC3A2.R13.4

Safe

19

33

36

36

MC3A2.D4.1
MC3A2.D4.14

Process

20

MC3A2.R11.3
MC3A2.R11.4
MC3A2.R11.5

Safe

34

37

37

MC3A2.R11.3
MC3A2.R11.4
MC3A2.R11.5

Safe

35

MC3A2.R1.3

Safe

21

MC3A2.R1.3

Exact

22

36

38

38

MC3A2.R8.2
MC3A2.R17.3

Safe

23

MC3A2.R8.2
MC3A2.R17.3

Safe

24

MC3A2.R5.6
MC3A2.R5.7
MC3A2.R8.3
MC3A2.R8.4
MC3A2.R8.5
MC3A2.R11.1
MC3A2.R21.2

Safe

25

MC3A2.R8.4
MC3A2.R8.5
MC3A2.R11.1
MC3A2.R21.2
MC3A2.R17.3

Safe

37

39

39

MC3A2.R8.4
MC3A2.R8.5
MC3A2.R11.1
MC3A2.R21.2
MC3A2.R17.3

Safe

38

40

40

MC3A2.R8.2

Safe

39

41

41

MC3A2.R5.6
MC3A2.R5.7
MC3A2.R8.2
MC3A2.R8.3
MC3A2.R8.4
MC3A2.R8.5
MC3A2.R11.1
MC3A2.R21.2

Safe

42

42

MC3A2.R1.3

Unsupported

26

40

43

43

MC3A2.D4.1
MC3A2.D4.14

Process

28

MC3A2.R11.1

Exact

29

41

44

44

MC3A2.R11.1
MC3A2.R11.2
MC3A2.R11.6
MC3A2.R11.7

Exact

42

45

45

MC3A2.D4.1

Process

46

MC3A2.R1.3

Process

30

43

46

47

MC3A2.D4.14
MC3A2.R18.1

Best-effort

44

47

48

MC3A2.D4.14
MC3A2.R18.1

Best-effort

31

45

48

49

MC3A2.D4.14
MC3A2.R18.2

Best-effort

46

49

50

MC3A2.R18.1

Best-effort

47

50

51

MC3A2.R1.3

Process

32

48

51

52

MC3A2.D4.14
MC3A2.R10.1
MC3A2.R12.2

Safe

49

52

53

MC3A2.R1.3

Unsupported

33

50

53

54

MC3A2.R18.3

Best-effort

34

51

54

55

MC3A2.R19.1

Best-effort

52

55

56

MC3A2.R1.3

Exact

53

56

57

MC3A2.R1.3

Exact

54

57

58

MC3A2.R1.3

Exact

55

58

59

MC3A2.R1.3

Unsupported

35

56

59

60

MC3A2.R1.3

Exact

36

57

60

61

MC3A2.R1.3

Exact

37

58

61

62

MC3A2.R1.3

Exact

38

MC3A2.R6.1

Exact

59

62

63

MC3A2.R18.7

Safe

60

63

64

MC3A2.R1.3

Exact

39

61

64

65

MC3A2.R11.4
MC3A2.R11.8
MC3A2.R19.2

Safe

40

62

65

66

MC3A2.R11.4
MC3A2.R11.8
MC3A2.R19.2

Safe

41

MC3A2.R9.1

Safe

63

66

67

MC3A2.R1.3

Exact

64

67

68

MC3A2.R1.3

Exact

65

68

69

MC3A2.R8.14

Safe

66

69

70

MC3A2.R8.14

Safe

67

70

71

MC3A2.R8.10

Safe

71

72

MC3A2.R1.3

Safe

72

73

MC3A2.R1.3

Exact

73

74

MC3A2.R1.3

Exact

68

74

75

MC3A2.R1.3

Exact

69

75

76

MC3A2.R18.8

Safe

70

76

77

MC3A2.R18.8

Safe

71

77

78

MC3A2.R17.6

Safe

72

78

79

MC3A2.R1.3

Exact

73

79

80

MC3A2.R8.2
MC3A2.R11.1

Safe

74

80

81

MC3A2.R1.3

Unsupported

75

81

82

MC3A2.R1.3

Exact

42

MC3A2.R9.2

Safe

76

82

83

MC3A2.R9.2

Safe

77

83

84

MC3A2.R9.2

Safe

44

78

84

85

MC3A2.R8.6

Exact

79

85

86

MC3A2.R8.2

Safe

80

86

87

MC3A2.R1.3

Exact

45

81

87

88

MC3A2.R17.1

Safe

43

82

88

89

MC3A2.R17.4

Exact

46

83

89

90

MC3A2.R1.3

Exact

91

MC3A2.R1.3

Exact

47

84

90

92

MC3A2.R1.3

Exact

48

85

91

93

MC3A2.R20.3

Exact

86

92

94

MC3A2.R1.3

Unsupported

49

MC3A2.R1.3

Exact

50

87

93

95

MC3A2.R20.6

Exact

51

88

94

96

MC3A2.R20.10

Safe

52

89

95

97

MC3A2.R20.10

Safe

53

90

96

98

MC3A2.R1.3

Exact

91

97

99

MC3A2.R1.3

Exact

92

98

100

MC3A2.R1.3

Exact

54

93

99

101

MC3A2.R21.1

Safe

55

94

100

102

MC3A2.R1.3

Safe

95

101

103

MC3A2.R1.3

Unsupported

56

MC3A2.R17.3
MC3A2.R20.1
MC3A2.R20.4
MC3A2.R21.2

Safe

96

102

104

MC3A2.R20.1

Safe

97

103

105

MC3A2.R20.1
MC3A2.R21.2

Safe

98

104

106

MC3A2.R20.4

Safe

57

MC3A2.R21.1
MC3A2.R21.2

Exact

99

105

107

MC3A2.R21.2

Safe

100

106

108

MC3A2.R21.1
MC3A2.R21.2

Safe

101

107

109

MC3A2.R21.1

Safe

60

102

108

110

MC3A2.D4.11

Best-effort

103

109

111

MC3A2.D4.11
MC3A2.R21.17
MC3A2.R21.18

Best-effort

61

MC3A2.R17.3
MC3A2.R21.2

Safe

62

104

110

112

MC3A2.R1.3

Safe

105

111

113

MC3A2.R1.3

Unsupported

106

112

114

MC3A2.R1.3

Exact

63

107

113

115

MC3A2.D4.11
MC3A2.R21.13

Safe

58

MC3A2.R21.1

Safe

108

114

116

MC3A2.R1.3

Safe

109

115

117

MC3A2.R1.3

Safe

110

116

118

MC3A2.R21.12

Safe

111

117

119

MC3A2.R21.12

Safe

112

118

120

MC3A2.D4.11

Safe

90

MC3A2.R21.7

Safe

94

MC3A2.R1.3

Unsupported

113

119

121

MC3A2.R1.3

Unsupported

114

120

122

MC3A2.R21.19

Safe

115

121

123

MC3A2.R21.19

Safe

116

122

124

MC3A2.R21.1
MC3A2.R21.2

Safe

117

123

125

MC3A2.R1.3

Unsupported

64

MC3A2.R21.1
MC3A2.R21.2
MC3A2.R21.4

Safe

118

124

126

MC3A2.R21.1
MC3A2.R21.2
MC3A2.R21.4

Safe

65

119

125

127

MC3A2.R21.4

Safe

120

126

128

MC3A2.R21.4

Safe

66

121

127

129

MC3A2.R21.4

Safe

67

MC3A2.R21.4
MC3A2.R21.5

Safe

122

128

130

MC3A2.R21.5

Safe

123

129

131

MC3A2.R21.5

Safe

130

132

MC3A2.R21.5

Safe

124

131

133

MC3A2.R21.5

Safe

68

MC3A2.R21.5

Safe

125

132

134

MC3A2.R21.5

Safe

69

126

133

135

MC3A2.R21.5

Safe

127

134

136

MC3A2.R21.5

Safe

135

137

MC3A2.R1.3

Safe

128

136

138

MC3A2.R1.3

Safe

70

129

137

139

MC3A2.R17.1

Safe

71

MC3A2.R17.1
MC3A2.R21.1
MC3A2.R21.2

Safe

130

138

140

MC3A2.R17.1
MC3A2.R21.1
MC3A2.R21.2

Safe

75

MC3A2.R17.1

Safe

76

MC3A2.R17.1

Safe

131

139

141

MC3A2.R17.1

Safe

132

140

142

MC3A2.R17.1

Safe

73

MC3A2.R17.1

Safe

74

MC3A2.R17.1

Safe

133

141

143

MC3A2.R17.1

Safe

134

142

144

MC3A2.R17.1

Safe

72

135

143

145

MC3A2.R17.1

Safe

146

MC3A2.R1.3

Safe

59

136

144

147

MC3A2.R1.3

Unsupported

137

145

148

MC3A2.R1.3

Exact

138

146

149

MC3A2.R21.6

Safe

139

147

150

MC3A2.R21.6

Safe

140

148

151

MC3A2.R21.6

Safe

77

141

149

152

MC3A2.R21.6

Safe

142

150

153

MC3A2.R21.6

Safe

78

143

151

154

MC3A2.R21.6

Safe

144

152

155

MC3A2.R21.6

Safe

79

MC3A2.R21.6

Safe

85

MC3A2.R21.6

Safe

145

153

156

MC3A2.R21.6

Safe

146

154

157

MC3A2.R21.6
MC3A2.R21.10

Safe

147

155

158

MC3A2.R21.6

Safe

148

156

159

MC3A2.R21.6

Safe

83

MC3A2.R21.6

Safe

84

MC3A2.R21.6

Safe

149

157

160

MC3A2.R21.6

Safe

82

MC3A2.R21.6

Safe

87

MC3A2.R21.6

Safe

150

158

161

MC3A2.R21.6

Safe

151

159

162

MC3A2.R21.6

Safe

152

160

163

MC3A2.R21.6

Safe

81

153

161

164

MC3A2.R21.6

Safe

97

MC3A2.R21.10

Safe

80

154

162

165

MC3A2.R21.6
MC3A2.R21.10

Safe

86

155

163

166

MC3A2.R21.6

Safe

164

167

MC3A2.R21.6

Safe

89

156

165

168

MC3A2.R21.6

Safe

157

166

169

MC3A2.R21.6

Safe

158

167

170

MC3A2.R21.6

Safe

88

159

168

171

MC3A2.R21.6

Safe

160

169

172

MC3A2.R21.6

Safe

161

170

173

MC3A2.R21.6

Safe

162

171

174

MC3A2.R21.6

Safe

163

172

175

MC3A2.R21.6

Safe

164

173

176

MC3A2.R21.6

Safe

165

174

177

MC3A2.R21.6

Safe

166

175

178

MC3A2.R21.6

Safe

167

176

179

MC3A2.R21.3

Safe

91

168

177

180

MC3A2.R21.3

Safe

178

MC3A2.R21.3

Safe

92

169

179

181

MC3A2.R21.3
MC3A2.R22.2

Safe

170

180

182

MC3A2.R21.3

Safe

171

181

183

MC3A2.R21.3

Safe

93

172

182

184

MC3A2.R21.8

Safe

173

183

185

MC3A2.R21.4

Safe

174

184

186

MC3A2.R21.19

Safe

185

187

MC3A2.R21.5
MC3A2.R21.8

Safe

175

186

188

MC3A2.R21.21

Safe

176

187

189

MC3A2.R21.9

Safe

177

188

190

MC3A2.R21.9

Safe

178

189

191

MC3A2.R21.9

Safe

95

179

190

192

MC3A2.R1.3

Unsupported

96

180

191

193

MC3A2.D4.11
MC3A2.R21.17
MC3A2.R21.18

Best-effort

181

192

194

MC3A2.D4.11
MC3A2.R21.18

Best-effort

182

193

195

MC3A2.R1.3

Unsupported

183

194

196

MC3A2.D4.11

Unsupported

184

195

197

MC3A2.R21.11

Safe

185

196

198

MC3A2.R21.11

Safe

199

MC3A2.R1.3

Unsupported

200

MC3A2.R1.3

Unsupported

201

MC3A2.R1.3

Unsupported

202

MC3A2.R1.3

Unsupported

203

MC3A2.R1.3

Unsupported

204

MC3A2.R1.3

Unsupported

197

205

MC3A2.R21.10

Safe

186

198

206

MC3A2.R21.6

Safe

187

199

207

MC3A2.D4.11

Unsupported

188

200

208

MC3A2.R1.3

Unsupported

189

201

209

MC3A2.D4.11

Best-effort

190

202

210

MC3A2.R1.3

Unsupported

191

203

211

MC3A2.R1.3

Unsupported

MISRA C:2012 Amendment 2 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 Amendment 2 coding standard [52].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 Amendment 2 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3A2.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3A2.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3A2.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3A2.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3A2.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3A2.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3A2.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3A2.D4.6

Dir 4.7
Required

no violation report for MC3A2.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3A2.D4.8

Dir 4.9
Advisory

no violation report for MC3A2.D4.9

Dir 4.10
Required

no violation report for MC3A2.D4.10

Dir 4.11
Required

no violation report for MC3A2.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3A2.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3A2.D4.13

Dir 4.14
Required

no violation report for MC3A2.D4.14

after: ensure that the external program input is adequately sanitized before use

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3A2.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3A2.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table for MC is reported with the indicated precision.;
after: nothing to do

Rule 1.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R1.4

Rule 2.1
Required
Undecidable
System

no violation report for MC3A2.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3A2.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3A2.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3A2.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3A2.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R2.7

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3A2.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3A2.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3A2.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3A2.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3A2.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3A2.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R6.2

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A2.R7.4

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3A2.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3A2.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3A2.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3A2.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3A2.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3A2.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3A2.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3A2.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3A2.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3A2.R8.14

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A2.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3A2.R9.5

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3A2.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3A2.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3A2.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3A2.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3A2.R11.9

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3A2.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3A2.R12.5

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3A2.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3A2.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3A2.R13.5

Rule 13.6
Mandatory
Decidable
Single T.U.

no violation report for MC3A2.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3A2.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3A2.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3A2.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3A2.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3A2.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3A2.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3A2.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3A2.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3A2.R17.4

Rule 17.5
Advisory
Undecidable
System

no violation report or caution report for MC3A2.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3A2.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3A2.R17.8

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3A2.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3A2.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3A2.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3A2.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3A2.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3A2.R18.8

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3A2.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3A2.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.10

Rule 21.11
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.11

Rule 21.12
Advisory
Decidable
Single T.U.

no violation report for MC3A2.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3A2.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R21.20

Rule 21.21
Required
Decidable
Single T.U.

no violation report for MC3A2.R21.21

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3A2.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3A2.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3A2.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3A2.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3A2.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3A2.R22.10

MISRA C:2012 Technical Corrigendum 2 Additional Information

This section contains the following additional information related to the support of the coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Technical Corrigendum 2 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 Technical Corrigendum 2 coding standard [54].

For all guidelines, the mapping between the MISRA C:2012 Technical Corrigendum 2 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Technical Corrigendum 2 Directive 1.1 maps to ECLAIR service MC3C2.D1.1,

  • MISRA C:2012 Technical Corrigendum 2 Rule 1.2 maps to ECLAIR service MC3C2.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3C2 synopsis: supported MISRA C:2012 Technical Corrigendum 2 guidelines

Id

Headline

Precision

MC3C2.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3C2.D2.1

All source files shall compile without any compilation errors

Process

MC3C2.D3.1

All code shall be traceable to documented requirements

Process

MC3C2.D4.1

Run-time failures shall be minimized

Process

MC3C2.D4.2

All usage of assembly language should be documented

Process

MC3C2.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3C2.D4.4

Sections of code should not be “commented out”

Heuristic

MC3C2.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3C2.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3C2.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3C2.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3C2.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3C2.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3C2.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3C2.D4.12

Dynamic memory allocation shall not be used

Process

MC3C2.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3C2.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3C2.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3C2.R1.2

Language extensions should not be used

Safe

MC3C2.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3C2.R1.4

Emergent language features shall not be used

Exact

MC3C2.R2.1

A project shall not contain unreachable code

Best-effort

MC3C2.R2.2

There shall be no dead code

Best-effort

MC3C2.R2.3

A project should not contain unused type declarations

Exact

MC3C2.R2.4

A project should not contain unused tag declarations

Exact

MC3C2.R2.5

A project should not contain unused macro definitions

Exact

MC3C2.R2.6

A function should not contain unused label declarations

Exact

MC3C2.R2.7

There should be no unused parameters in functions

Exact

MC3C2.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3C2.R3.2

Line-splicing shall not be used in // comments

Exact

MC3C2.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3C2.R4.2

Trigraphs should not be used

Exact

MC3C2.R5.1

External identifiers shall be distinct

Exact

MC3C2.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3C2.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3C2.R5.4

Macro identifiers shall be distinct

Exact

MC3C2.R5.5

Identifiers shall be distinct from macro names

Exact

MC3C2.R5.6

A typedef name shall be a unique identifier

Exact

MC3C2.R5.7

A tag name shall be a unique identifier

Exact

MC3C2.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3C2.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3C2.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3C2.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3C2.R7.1

Octal constants shall not be used

Exact

MC3C2.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3C2.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3C2.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3C2.R8.1

Types shall be explicitly specified

Exact

MC3C2.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3C2.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3C2.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3C2.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3C2.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3C2.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3C2.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3C2.R8.9

An object should be defined at block scope if its identifier only appears in a single function

Exact

MC3C2.R8.10

An inline function shall be declared with the static storage class

Exact

MC3C2.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3C2.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3C2.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3C2.R8.14

The restrict type qualifier shall not be used

Exact

MC3C2.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3C2.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3C2.R9.3

Arrays shall not be partially initialized

Exact

MC3C2.R9.4

An element of an object shall not be initialized more than once

Complete

MC3C2.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3C2.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3C2.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3C2.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3C2.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3C2.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3C2.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3C2.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3C2.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3C2.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3C2.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3C2.R11.3

A cast shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3C2.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3C2.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3C2.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3C2.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3C2.R11.8

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

Exact

MC3C2.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3C2.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3C2.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3C2.R12.3

The comma operator should not be used

Exact

MC3C2.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3C2.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3C2.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3C2.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders

Safe

MC3C2.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3C2.R13.4

The result of an assignment operator should not be used

Exact

MC3C2.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3C2.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3C2.R14.1

A loop counter shall not have essentially floating type

Safe

MC3C2.R14.2

A for loop shall be well-formed

Safe

MC3C2.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3C2.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3C2.R15.1

The goto statement should not be used

Exact

MC3C2.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3C2.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3C2.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3C2.R15.5

A function should have a single point of exit at the end

Exact

MC3C2.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3C2.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3C2.R16.1

All switch statements shall be well-formed

Exact

MC3C2.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3C2.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3C2.R16.4

Every switch statement shall have a default label

Exact

MC3C2.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3C2.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3C2.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3C2.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3C2.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3C2.R17.3

A function shall not be declared implicitly

Exact

MC3C2.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3C2.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3C2.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3C2.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3C2.R17.8

A function parameter should not be modified

Precise

MC3C2.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3C2.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3C2.R18.3

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Safe

MC3C2.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3C2.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3C2.R18.6

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3C2.R18.7

Flexible array members shall not be declared

Exact

MC3C2.R18.8

Variable-length array types shall not be used

Exact

MC3C2.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3C2.R19.2

The union keyword should not be used

Exact

MC3C2.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3C2.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3C2.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3C2.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3C2.R20.5

#undef should not be used

Exact

MC3C2.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3C2.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3C2.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3C2.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3C2.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3C2.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3C2.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3C2.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3C2.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3C2.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3C2.R21.2

A reserved identifier or reserved macro name shall not be declared

Exact

MC3C2.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3C2.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3C2.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3C2.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3C2.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3C2.R21.8

The Standard Library termination functions of <stdlib.h> shall not be used

Exact

MC3C2.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3C2.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3C2.R21.11

The standard header file <tgmath.h> shall not be used

Exact

MC3C2.R21.12

The exception handling features of <fenv.h> should not be used

Exact

MC3C2.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3C2.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3C2.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3C2.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3C2.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3C2.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3C2.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3C2.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3C2.R21.21

The Standard Library function system of <stdlib.h> shall not be used

Exact

MC3C2.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3C2.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3C2.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3C2.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3C2.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3C2.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3C2.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3C2.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3C2.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3C2.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

Coverage of Undefined Behaviours for MISRA C:2012 Technical Corrigendum 2

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [54]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3C2.R1.3

Exact

2

MC3C2.R1.3

Exact

3

MC3C2.R20.10

Unsupported

3

3

3

MC3C2.R1.3

Exact

4

4

4

MC3C2.R1.3

Exact

5

5

MC3C2.R1.3

Unsupported

5

6

6

MC3C2.R1.3

Exact

6

7

7

MC3C2.R1.3

Unsupported

5

MC3C2.R5.2

Exact

6

MC3C2.R17.3

Exact

8

7

8

8

MC3C2.R1.3

Exact

8

9

9

MC3C2.D4.12
MC3C2.R18.6
MC3C2.R21.3

Safe

9

MC3C2.D4.12
MC3C2.R18.6
MC3C2.R21.3

Safe

9

10

10

MC3C2.D4.12
MC3C2.R18.6
MC3C2.R21.3

Safe

10

11

11

MC3C2.R1.3

Safe

11

12

12

MC3C2.R1.3

Unsupported

12

13

13

MC3C2.R11.2
MC3C2.R11.3
MC3C2.R11.4
MC3C2.R11.5

Safe

13

14

14

MC3C2.R1.3

Unsupported

10

14

15

15

MC3C2.R5.6
MC3C2.R5.7
MC3C2.R8.3

Safe

15

MC3C2.D4.1
MC3C2.D4.14
MC3C2.R10.3

Process

16

16

MC3C2.R18.8

Safe

15

17

17

MC3C2.D4.1
MC3C2.D4.14
MC3C2.R10.3

Process

16

18

18

MC3C2.D4.1
MC3C2.D4.14
MC3C2.R10.3

Process

17

19

19

MC3C2.R9.1
MC3C2.R11.2
MC3C2.R11.3
MC3C2.R11.4
MC3C2.R11.5
MC3C2.R19.1

Process

16

18

20

20

MC3C2.R1.3

Exact

21

21

MC3C2.R1.3

Safe

19

22

22

MC3C2.R1.3

Exact

17

20

23

23

MC3C2.R1.3

Exact

21

24

24

MC3C2.R11.1
MC3C2.R11.2
MC3C2.R11.4
MC3C2.R11.6

Safe

22

25

25

MC3C2.R11.2
MC3C2.R11.3
MC3C2.R11.5

Safe

27

23

26

26

MC3C2.R11.1

Safe

4

24

27

27

MC3C2.R1.3

Exact

25

28

28

MC3C2.R1.3

Exact

26

29

29

MC3C2.R1.3

Exact

27

30

30

MC3C2.R1.3

Exact

7

28

31

31

MC3C2.R5.1
MC3C2.R5.2
MC3C2.R5.3
MC3C2.R5.4
MC3C2.R5.5

Exact

29

32

32

MC3C2.R21.2

Exact

11

MC3C2.R1.3

Exact

12

30

33

33

MC3C2.R7.4
MC3C2.R11.4
MC3C2.R11.8

Safe

13

MC3C2.R1.3

Exact

14

MC3C2.R20.2

Exact

31

34

34

MC3C2.R20.2

Exact

18

32

35

35

MC3C2.R13.2
MC3C2.R13.3
MC3C2.R13.4

Safe

19

33

36

36

MC3C2.D4.1
MC3C2.D4.14

Process

20

MC3C2.R11.3
MC3C2.R11.4
MC3C2.R11.5

Safe

34

37

37

MC3C2.R11.3
MC3C2.R11.4
MC3C2.R11.5

Safe

35

MC3C2.R1.3

Safe

21

MC3C2.R1.3

Exact

22

36

38

38

MC3C2.R8.2
MC3C2.R17.3

Safe

23

MC3C2.R8.2
MC3C2.R17.3

Safe

24

MC3C2.R5.6
MC3C2.R5.7
MC3C2.R8.3
MC3C2.R8.4
MC3C2.R8.5
MC3C2.R11.1
MC3C2.R21.2

Safe

25

MC3C2.R8.4
MC3C2.R8.5
MC3C2.R11.1
MC3C2.R21.2
MC3C2.R17.3

Safe

37

39

39

MC3C2.R8.4
MC3C2.R8.5
MC3C2.R11.1
MC3C2.R21.2
MC3C2.R17.3

Safe

38

40

40

MC3C2.R8.2

Safe

39

41

41

MC3C2.R5.6
MC3C2.R5.7
MC3C2.R8.2
MC3C2.R8.3
MC3C2.R8.4
MC3C2.R8.5
MC3C2.R11.1
MC3C2.R21.2

Safe

42

42

MC3C2.R1.3

Unsupported

26

40

43

43

MC3C2.D4.1
MC3C2.D4.14

Process

28

MC3C2.R11.1

Exact

29

41

44

44

MC3C2.R11.1
MC3C2.R11.2
MC3C2.R11.6
MC3C2.R11.7

Exact

42

45

45

MC3C2.D4.1

Process

46

MC3C2.R1.3

Process

30

43

46

47

MC3C2.D4.14
MC3C2.R18.1

Best-effort

44

47

48

MC3C2.D4.14
MC3C2.R18.1

Best-effort

31

45

48

49

MC3C2.D4.14
MC3C2.R18.2

Best-effort

46

49

50

MC3C2.R18.1

Best-effort

47

50

51

MC3C2.R1.3

Process

32

48

51

52

MC3C2.D4.14
MC3C2.R10.1
MC3C2.R12.2

Safe

49

52

53

MC3C2.R1.3

Unsupported

33

50

53

54

MC3C2.R18.3

Best-effort

34

51

54

55

MC3C2.R19.1

Best-effort

52

55

56

MC3C2.R1.3

Exact

53

56

57

MC3C2.R1.3

Exact

54

57

58

MC3C2.R1.3

Exact

55

58

59

MC3C2.R1.3

Unsupported

35

56

59

60

MC3C2.R1.3

Exact

36

57

60

61

MC3C2.R1.3

Exact

37

58

61

62

MC3C2.R1.3

Exact

38

MC3C2.R6.1

Exact

59

62

63

MC3C2.R18.7

Safe

60

63

64

MC3C2.R1.3

Exact

39

61

64

65

MC3C2.R11.4
MC3C2.R11.8
MC3C2.R19.2

Safe

40

62

65

66

MC3C2.R11.4
MC3C2.R11.8
MC3C2.R19.2

Safe

41

MC3C2.R9.1

Safe

63

66

67

MC3C2.R1.3

Exact

64

67

68

MC3C2.R1.3

Exact

65

68

69

MC3C2.R8.14

Safe

66

69

70

MC3C2.R8.14

Safe

67

70

71

MC3C2.R8.10

Safe

71

72

MC3C2.R1.3

Safe

72

73

MC3C2.R1.3

Exact

73

74

MC3C2.R1.3

Exact

68

74

75

MC3C2.R1.3

Exact

69

75

76

MC3C2.R18.8

Safe

70

76

77

MC3C2.R18.8

Safe

71

77

78

MC3C2.R17.6

Safe

72

78

79

MC3C2.R1.3

Exact

73

79

80

MC3C2.R8.2
MC3C2.R11.1

Safe

74

80

81

MC3C2.R1.3

Unsupported

75

81

82

MC3C2.R1.3

Exact

42

MC3C2.R9.2

Safe

76

82

83

MC3C2.R9.2

Safe

77

83

84

MC3C2.R9.2

Safe

44

78

84

85

MC3C2.R8.6

Exact

79

85

86

MC3C2.R8.2

Safe

80

86

87

MC3C2.R1.3

Exact

45

81

87

88

MC3C2.R17.1

Safe

43

82

88

89

MC3C2.R17.4

Exact

46

83

89

90

MC3C2.R1.3

Exact

91

MC3C2.R1.3

Exact

47

84

90

92

MC3C2.R1.3

Exact

48

85

91

93

MC3C2.R20.3

Exact

86

92

94

MC3C2.R1.3

Unsupported

49

MC3C2.R1.3

Exact

50

87

93

95

MC3C2.R20.6

Exact

51

88

94

96

MC3C2.R20.10

Safe

52

89

95

97

MC3C2.R20.10

Safe

53

90

96

98

MC3C2.R1.3

Exact

91

97

99

MC3C2.R1.3

Exact

92

98

100

MC3C2.R1.3

Exact

54

93

99

101

MC3C2.R21.1

Safe

55

94

100

102

MC3C2.R1.3

Safe

95

101

103

MC3C2.R1.3

Unsupported

56

MC3C2.R17.3
MC3C2.R20.1
MC3C2.R20.4
MC3C2.R21.2

Safe

96

102

104

MC3C2.R20.1

Safe

97

103

105

MC3C2.R20.1
MC3C2.R21.2

Safe

98

104

106

MC3C2.R20.4

Safe

57

MC3C2.R21.1
MC3C2.R21.2

Exact

99

105

107

MC3C2.R21.2

Safe

100

106

108

MC3C2.R21.1
MC3C2.R21.2

Safe

101

107

109

MC3C2.R21.1

Safe

60

102

108

110

MC3C2.D4.11

Best-effort

103

109

111

MC3C2.D4.11
MC3C2.R21.17
MC3C2.R21.18

Best-effort

61

MC3C2.R17.3
MC3C2.R21.2

Safe

62

104

110

112

MC3C2.R1.3

Safe

105

111

113

MC3C2.R1.3

Unsupported

106

112

114

MC3C2.R1.3

Exact

63

107

113

115

MC3C2.D4.11
MC3C2.R21.13

Safe

58

MC3C2.R21.1

Safe

108

114

116

MC3C2.R1.3

Safe

109

115

117

MC3C2.R1.3

Safe

110

116

118

MC3C2.R21.12

Safe

111

117

119

MC3C2.R21.12

Safe

112

118

120

MC3C2.D4.11

Safe

90

MC3C2.R21.7

Safe

94

MC3C2.R1.3

Unsupported

113

119

121

MC3C2.R1.3

Unsupported

114

120

122

MC3C2.R21.19

Safe

115

121

123

MC3C2.R21.19

Safe

116

122

124

MC3C2.R21.1
MC3C2.R21.2

Safe

117

123

125

MC3C2.R1.3

Unsupported

64

MC3C2.R21.1
MC3C2.R21.2
MC3C2.R21.4

Safe

118

124

126

MC3C2.R21.1
MC3C2.R21.2
MC3C2.R21.4

Safe

65

119

125

127

MC3C2.R21.4

Safe

120

126

128

MC3C2.R21.4

Safe

66

121

127

129

MC3C2.R21.4

Safe

67

MC3C2.R21.4
MC3C2.R21.5

Safe

122

128

130

MC3C2.R21.5

Safe

123

129

131

MC3C2.R21.5

Safe

130

132

MC3C2.R21.5

Safe

124

131

133

MC3C2.R21.5

Safe

68

MC3C2.R21.5

Safe

125

132

134

MC3C2.R21.5

Safe

69

126

133

135

MC3C2.R21.5

Safe

127

134

136

MC3C2.R21.5

Safe

135

137

MC3C2.R1.3

Safe

128

136

138

MC3C2.R1.3

Safe

70

129

137

139

MC3C2.R17.1

Safe

71

MC3C2.R17.1
MC3C2.R21.1
MC3C2.R21.2

Safe

130

138

140

MC3C2.R17.1
MC3C2.R21.1
MC3C2.R21.2

Safe

75

MC3C2.R17.1

Safe

76

MC3C2.R17.1

Safe

131

139

141

MC3C2.R17.1

Safe

132

140

142

MC3C2.R17.1

Safe

73

MC3C2.R17.1

Safe

74

MC3C2.R17.1

Safe

133

141

143

MC3C2.R17.1

Safe

134

142

144

MC3C2.R17.1

Safe

72

135

143

145

MC3C2.R17.1

Safe

146

MC3C2.R1.3

Safe

59

136

144

147

MC3C2.R1.3

Unsupported

137

145

148

MC3C2.R1.3

Exact

138

146

149

MC3C2.R21.6

Safe

139

147

150

MC3C2.R21.6

Safe

140

148

151

MC3C2.R21.6

Safe

77

141

149

152

MC3C2.R21.6

Safe

142

150

153

MC3C2.R21.6

Safe

78

143

151

154

MC3C2.R21.6

Safe

144

152

155

MC3C2.R21.6

Safe

79

MC3C2.R21.6

Safe

85

MC3C2.R21.6

Safe

145

153

156

MC3C2.R21.6

Safe

146

154

157

MC3C2.R21.6
MC3C2.R21.10

Safe

147

155

158

MC3C2.R21.6

Safe

148

156

159

MC3C2.R21.6

Safe

83

MC3C2.R21.6

Safe

84

MC3C2.R21.6

Safe

149

157

160

MC3C2.R21.6

Safe

82

MC3C2.R21.6

Safe

87

MC3C2.R21.6

Safe

150

158

161

MC3C2.R21.6

Safe

151

159

162

MC3C2.R21.6

Safe

152

160

163

MC3C2.R21.6

Safe

81

153

161

164

MC3C2.R21.6

Safe

97

MC3C2.R21.10

Safe

80

154

162

165

MC3C2.R21.6
MC3C2.R21.10

Safe

86

155

163

166

MC3C2.R21.6

Safe

164

167

MC3C2.R21.6

Safe

89

156

165

168

MC3C2.R21.6

Safe

157

166

169

MC3C2.R21.6

Safe

158

167

170

MC3C2.R21.6

Safe

88

159

168

171

MC3C2.R21.6

Safe

160

169

172

MC3C2.R21.6

Safe

161

170

173

MC3C2.R21.6

Safe

162

171

174

MC3C2.R21.6

Safe

163

172

175

MC3C2.R21.6

Safe

164

173

176

MC3C2.R21.6

Safe

165

174

177

MC3C2.R21.6

Safe

166

175

178

MC3C2.R21.6

Safe

167

176

179

MC3C2.R21.3

Safe

91

168

177

180

MC3C2.R21.3

Safe

178

MC3C2.R21.3

Safe

92

169

179

181

MC3C2.R21.3
MC3C2.R22.2

Safe

170

180

182

MC3C2.R21.3

Safe

171

181

183

MC3C2.R21.3

Safe

93

172

182

184

MC3C2.R21.8

Safe

173

183

185

MC3C2.R21.4

Safe

174

184

186

MC3C2.R21.19

Safe

185

187

MC3C2.R21.5
MC3C2.R21.8

Safe

175

186

188

MC3C2.R21.21

Safe

176

187

189

MC3C2.R21.9

Safe

177

188

190

MC3C2.R21.9

Safe

178

189

191

MC3C2.R21.9

Safe

95

179

190

192

MC3C2.R1.3

Unsupported

96

180

191

193

MC3C2.D4.11
MC3C2.R21.17
MC3C2.R21.18

Best-effort

181

192

194

MC3C2.D4.11
MC3C2.R21.18

Best-effort

182

193

195

MC3C2.R1.3

Unsupported

183

194

196

MC3C2.D4.11

Unsupported

184

195

197

MC3C2.R21.11

Safe

185

196

198

MC3C2.R21.11

Safe

199

MC3C2.R1.3

Unsupported

200

MC3C2.R1.3

Unsupported

201

MC3C2.R1.3

Unsupported

202

MC3C2.R1.3

Unsupported

203

MC3C2.R1.3

Unsupported

204

MC3C2.R1.3

Unsupported

197

205

MC3C2.R21.10

Safe

186

198

206

MC3C2.R21.6

Safe

187

199

207

MC3C2.D4.11

Unsupported

188

200

208

MC3C2.R1.3

Unsupported

189

201

209

MC3C2.D4.11

Best-effort

190

202

210

MC3C2.R1.3

Unsupported

191

203

211

MC3C2.R1.3

Unsupported

MISRA C:2012 Technical Corrigendum 2 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 Technical Corrigendum 2 coding standard [54].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 Technical Corrigendum 2 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3C2.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3C2.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3C2.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3C2.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3C2.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3C2.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3C2.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3C2.D4.6

Dir 4.7
Required

no violation report for MC3C2.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3C2.D4.8

Dir 4.9
Advisory

no violation report for MC3C2.D4.9

Dir 4.10
Required

no violation report for MC3C2.D4.10

Dir 4.11
Required

no violation report for MC3C2.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3C2.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3C2.D4.13

Dir 4.14
Required

no violation report for MC3C2.D4.14

after: ensure that the external program input is adequately sanitized before use

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3C2.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3C2.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table for MC is reported with the indicated precision.;
after: nothing to do

Rule 1.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R1.4

Rule 2.1
Required
Undecidable
System

no violation report for MC3C2.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3C2.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3C2.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3C2.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3C2.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R2.7

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3C2.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3C2.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3C2.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3C2.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3C2.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3C2.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R6.2

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3C2.R7.4

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3C2.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3C2.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3C2.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3C2.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3C2.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3C2.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3C2.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3C2.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3C2.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3C2.R8.14

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3C2.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3C2.R9.5

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3C2.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3C2.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3C2.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3C2.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3C2.R11.9

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3C2.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3C2.R12.5

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3C2.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3C2.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3C2.R13.5

Rule 13.6
Required
Decidable
Single T.U.

no violation report for MC3C2.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3C2.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3C2.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3C2.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3C2.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3C2.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3C2.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3C2.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3C2.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3C2.R17.4

Rule 17.5
Required
Undecidable
System

no violation report or caution report for MC3C2.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3C2.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3C2.R17.8

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3C2.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3C2.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3C2.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3C2.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3C2.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3C2.R18.8

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3C2.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3C2.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.10

Rule 21.11
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.11

Rule 21.12
Advisory
Decidable
Single T.U.

no violation report for MC3C2.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3C2.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R21.20

Rule 21.21
Required
Decidable
Single T.U.

no violation report for MC3C2.R21.21

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3C2.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3C2.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3C2.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3C2.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3C2.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3C2.R22.10

MISRA C:2012 Amendment 3 Additional Information

This section contains the following additional information related to the support of the coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Amendment 3 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 Amendment 3 coding standard [55].

For all guidelines, the mapping between the MISRA C:2012 Amendment 3 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Amendment 3 Directive 1.1 maps to ECLAIR service MC3A3.D1.1,

  • MISRA C:2012 Amendment 3 Rule 1.2 maps to ECLAIR service MC3A3.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3A3 synopsis: supported MISRA C:2012 Amendment 3 guidelines

Id

Headline

Precision

MC3A3.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3A3.D2.1

All source files shall compile without any compilation errors

Process

MC3A3.D3.1

All code shall be traceable to documented requirements

Process

MC3A3.D4.1

Run-time failures shall be minimized

Process

MC3A3.D4.2

All usage of assembly language should be documented

Process

MC3A3.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3A3.D4.4

Sections of code should not be “commented out”

Heuristic

MC3A3.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3A3.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3A3.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3A3.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3A3.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3A3.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3A3.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3A3.D4.12

Dynamic memory allocation shall not be used

Process

MC3A3.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3A3.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3A3.D4.15

Evaluation of floating-point expressions shall not lead to the undetected generation of infinities and NaNs

Complete

MC3A3.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3A3.R1.2

Language extensions should not be used

Safe

MC3A3.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3A3.R1.4

Emergent language features shall not be used

Exact

MC3A3.R1.5

Obsolescent language features shall not be used

Complete

MC3A3.R2.1

A project shall not contain unreachable code

Best-effort

MC3A3.R2.2

There shall be no dead code

Best-effort

MC3A3.R2.3

A project should not contain unused type declarations

Exact

MC3A3.R2.4

A project should not contain unused tag declarations

Exact

MC3A3.R2.5

A project should not contain unused macro definitions

Exact

MC3A3.R2.6

A function should not contain unused label declarations

Exact

MC3A3.R2.7

There should be no unused parameters in functions

Exact

MC3A3.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3A3.R3.2

Line-splicing shall not be used in // comments

Exact

MC3A3.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3A3.R4.2

Trigraphs should not be used

Exact

MC3A3.R5.1

External identifiers shall be distinct

Exact

MC3A3.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3A3.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3A3.R5.4

Macro identifiers shall be distinct

Exact

MC3A3.R5.5

Identifiers shall be distinct from macro names

Exact

MC3A3.R5.6

A typedef name shall be a unique identifier

Exact

MC3A3.R5.7

A tag name shall be a unique identifier

Exact

MC3A3.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3A3.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3A3.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3A3.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3A3.R6.3

A bit field shall not be declared as a member of a union

Exact

MC3A3.R7.1

Octal constants shall not be used

Exact

MC3A3.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3A3.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3A3.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3A3.R7.5

The argument of an integer constant macro shall have an appropriate form

Exact

MC3A3.R8.1

Types shall be explicitly specified

Exact

MC3A3.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3A3.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3A3.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3A3.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3A3.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3A3.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3A3.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3A3.R8.9

An object should be defined at block scope if its identifier only appears in a single function

Exact

MC3A3.R8.10

An inline function shall be declared with the static storage class

Exact

MC3A3.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3A3.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3A3.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3A3.R8.14

The restrict type qualifier shall not be used

Exact

MC3A3.R8.15

All declarations of an object with an explicit alignment specification shall specify the same alignment

Exact

MC3A3.R8.16

The alignment specification of zero should not appear in an object declaration

Exact

MC3A3.R8.17

At most one explicit alignment specifier should appear in an object declaration

Exact

MC3A3.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3A3.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3A3.R9.3

Arrays shall not be partially initialized

Exact

MC3A3.R9.4

An element of an object shall not be initialized more than once

Complete

MC3A3.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3A3.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3A3.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3A3.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3A3.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3A3.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3A3.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3A3.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3A3.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3A3.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3A3.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3A3.R11.3

A cast shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3A3.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3A3.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3A3.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3A3.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3A3.R11.8

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

Exact

MC3A3.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3A3.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3A3.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3A3.R12.3

The comma operator should not be used

Exact

MC3A3.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3A3.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3A3.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3A3.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders

Safe

MC3A3.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3A3.R13.4

The result of an assignment operator should not be used

Exact

MC3A3.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3A3.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3A3.R14.1

A loop counter shall not have essentially floating type

Safe

MC3A3.R14.2

A for loop shall be well-formed

Safe

MC3A3.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3A3.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3A3.R15.1

The goto statement should not be used

Exact

MC3A3.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3A3.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3A3.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3A3.R15.5

A function should have a single point of exit at the end

Exact

MC3A3.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3A3.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3A3.R16.1

All switch statements shall be well-formed

Exact

MC3A3.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3A3.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3A3.R16.4

Every switch statement shall have a default label

Exact

MC3A3.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3A3.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3A3.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3A3.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3A3.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3A3.R17.3

A function shall not be declared implicitly

Exact

MC3A3.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3A3.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3A3.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3A3.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3A3.R17.8

A function parameter should not be modified

Precise

MC3A3.R17.9

A function declared with a _Noreturn function specifier shall not return to its caller

Precise

MC3A3.R17.10

A function declared with a _Noreturn function specifier shall have * void* return type

Exact

MC3A3.R17.11

A function that never returns should be declared with a _Noreturn function specifier

Best-effort

MC3A3.R17.12

A function identifier should only be used with either a preceding &, or with a parenthesized parameter list

Exact

MC3A3.R17.13

A function type shall not be type qualified

Exact

MC3A3.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3A3.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3A3.R18.3

The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Safe

MC3A3.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3A3.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3A3.R18.6

The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3A3.R18.7

Flexible array members shall not be declared

Exact

MC3A3.R18.8

Variable-length array types shall not be used

Exact

MC3A3.R18.9

An object with temporary lifetime shall not undergo array-to-pointer conversion

Exact

MC3A3.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3A3.R19.2

The union keyword should not be used

Exact

MC3A3.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3A3.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3A3.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3A3.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3A3.R20.5

#undef should not be used

Exact

MC3A3.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3A3.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3A3.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3A3.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3A3.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3A3.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3A3.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3A3.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3A3.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3A3.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3A3.R21.2

A reserved identifier or reserved macro name shall not be declared

Exact

MC3A3.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3A3.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3A3.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3A3.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3A3.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3A3.R21.8

The Standard Library termination functions of <stdlib.h> shall not be used

Exact

MC3A3.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3A3.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3A3.R21.11

The standard header file <tgmath.h> should not be used

Exact

MC3A3.R21.12

The standard header file <fenv.h> shall not be used

Exact

MC3A3.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3A3.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3A3.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3A3.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3A3.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3A3.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3A3.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3A3.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3A3.R21.21

The Standard Library function system of <stdlib.h> shall not be used

Exact

MC3A3.R21.22

All operand arguments to any type-generic macros declared in <tgmath.h> shall have an appropriate essential type

Exact

MC3A3.R21.23

All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type

Exact

MC3A3.R21.24

The random number generator functions of <stdlib.h> shall not be used

Exact

MC3A3.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3A3.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3A3.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3A3.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3A3.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3A3.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3A3.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3A3.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3A3.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3A3.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

MC3A3.R23.1

A generic selection should only be expanded from a macro

Exact

MC3A3.R23.2

A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression

Exact

MC3A3.R23.3

A generic selection should contain at least one non-default association

Exact

MC3A3.R23.4

A generic association shall list an appropriate type

Exact

MC3A3.R23.5

A generic selection should not depend on implicit pointer type conversion

Exact

MC3A3.R23.6

The controlling expression of a generic selection shall have an essential type that matches its standard type

Exact

MC3A3.R23.7

A generic selection that is expanded from a macro should evaluate its argument only once

Exact

MC3A3.R23.8

A default association shall appear as either the first or the last association of a generic selection

Exact

Coverage of Undefined Behaviours for MISRA C:2012 Amendment 3

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [55]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3A3.R1.3

Exact

2

MC3A3.R1.3

Exact

3

MC3A3.R20.10

Unsupported

3

3

3

MC3A3.R1.3

Exact

4

4

4

MC3A3.R1.3

Exact

5

5

MC3A3.R1.3

Unsupported

5

6

6

MC3A3.R1.3

Exact

6

7

7

MC3A3.R1.3

Unsupported

5

MC3A3.R5.2

Exact

6

MC3A3.R17.3

Exact

8

7

8

8

MC3A3.R1.3

Exact

8

9

9

MC3A3.R18.9

Safe

9

MC3A3.D4.12
MC3A3.R18.6
MC3A3.R21.3

Safe

9

10

10

MC3A3.D4.12
MC3A3.R18.6
MC3A3.R21.3

Safe

10

11

11

MC3A3.R1.3

Safe

11

12

12

MC3A3.R1.3

Unsupported

12

13

13

MC3A3.R11.2
MC3A3.R11.3
MC3A3.R11.4
MC3A3.R11.5

Safe

13

14

14

MC3A3.R1.3

Unsupported

10

14

15

15

MC3A3.R5.6
MC3A3.R5.7
MC3A3.R8.3

Safe

15

MC3A3.D4.1
MC3A3.D4.14
MC3A3.R10.3

Process

16

16

MC3A3.R18.8

Safe

15

17

17

MC3A3.D4.1
MC3A3.D4.14
MC3A3.R10.3

Process

16

18

18

MC3A3.D4.1
MC3A3.D4.14
MC3A3.R10.3

Process

17

19

19

MC3A3.R9.1
MC3A3.R11.2
MC3A3.R11.3
MC3A3.R11.4
MC3A3.R11.5
MC3A3.R19.1

Process

16

18

20

20

MC3A3.R1.3

Exact

21

21

MC3A3.R1.3

Safe

19

22

22

MC3A3.R1.3

Exact

17

20

23

23

MC3A3.R1.3

Exact

21

24

24

MC3A3.R11.1
MC3A3.R11.2
MC3A3.R11.4
MC3A3.R11.6

Safe

22

25

25

MC3A3.R11.2
MC3A3.R11.3
MC3A3.R11.5

Safe

27

23

26

26

MC3A3.R11.1

Safe

4

24

27

27

MC3A3.R1.3

Exact

25

28

28

MC3A3.R1.3

Exact

26

29

29

MC3A3.R1.3

Exact

27

30

30

MC3A3.R1.3

Exact

7

28

31

31

MC3A3.R5.1
MC3A3.R5.2
MC3A3.R5.3
MC3A3.R5.4
MC3A3.R5.5

Exact

29

32

32

MC3A3.R21.2

Exact

11

MC3A3.R1.3

Exact

12

30

33

33

MC3A3.R7.4
MC3A3.R11.4
MC3A3.R11.8

Safe

13

MC3A3.R1.3

Exact

14

MC3A3.R20.2

Exact

31

34

34

MC3A3.R20.2

Exact

18

32

35

35

MC3A3.R13.2
MC3A3.R13.3
MC3A3.R13.4

Safe

19

33

36

36

MC3A3.D4.1
MC3A3.D4.14

Process

20

MC3A3.R11.3
MC3A3.R11.4
MC3A3.R11.5

Safe

34

37

37

MC3A3.R11.3
MC3A3.R11.4
MC3A3.R11.5

Safe

35

MC3A3.R18.9

Safe

21

MC3A3.R1.3

Exact

22

36

38

38

MC3A3.R8.2
MC3A3.R17.3

Safe

23

MC3A3.R8.2
MC3A3.R17.3

Safe

24

MC3A3.R5.6
MC3A3.R5.7
MC3A3.R8.3
MC3A3.R8.4
MC3A3.R8.5
MC3A3.R11.1
MC3A3.R21.2

Safe

25

MC3A3.R8.4
MC3A3.R8.5
MC3A3.R11.1
MC3A3.R21.2
MC3A3.R17.3

Safe

37

39

39

MC3A3.R8.4
MC3A3.R8.5
MC3A3.R11.1
MC3A3.R21.2
MC3A3.R17.3

Safe

38

40

40

MC3A3.R8.2

Safe

39

41

41

MC3A3.R5.6
MC3A3.R5.7
MC3A3.R8.2
MC3A3.R8.3
MC3A3.R8.4
MC3A3.R8.5
MC3A3.R11.1
MC3A3.R21.2

Safe

42

42

MC3A3.R1.3

Unsupported

26

40

43

43

MC3A3.D4.1
MC3A3.D4.14

Process

28

MC3A3.R11.1

Exact

29

41

44

44

MC3A3.R11.1
MC3A3.R11.2
MC3A3.R11.6
MC3A3.R11.7

Exact

42

45

45

MC3A3.D4.1

Process

46

MC3A3.R1.3

Process

30

43

46

47

MC3A3.D4.14
MC3A3.R18.1

Best-effort

44

47

48

MC3A3.D4.14
MC3A3.R18.1

Best-effort

31

45

48

49

MC3A3.D4.14
MC3A3.R18.2

Best-effort

46

49

50

MC3A3.R18.1

Best-effort

47

50

51

MC3A3.R1.3

Process

32

48

51

52

MC3A3.D4.14
MC3A3.R10.1
MC3A3.R12.2

Safe

49

52

53

MC3A3.R1.3

Unsupported

33

50

53

54

MC3A3.R18.3

Best-effort

34

51

54

55

MC3A3.R19.1

Best-effort

52

55

56

MC3A3.R1.3

Exact

53

56

57

MC3A3.R1.3

Exact

54

57

58

MC3A3.R1.3

Exact

55

58

59

MC3A3.R1.3

Unsupported

35

56

59

60

MC3A3.R1.3

Exact

36

57

60

61

MC3A3.R1.3

Exact

37

58

61

62

MC3A3.R1.3

Exact

38

MC3A3.R6.1

Exact

59

62

63

MC3A3.R18.7

Safe

60

63

64

MC3A3.R1.3

Exact

39

61

64

65

MC3A3.R11.4
MC3A3.R11.8
MC3A3.R19.2

Safe

40

62

65

66

MC3A3.R11.4
MC3A3.R11.8
MC3A3.R19.2

Safe

41

MC3A3.R9.1

Safe

63

66

67

MC3A3.R17.13

Exact

64

67

68

MC3A3.R1.3

Exact

65

68

69

MC3A3.R8.14

Safe

66

69

70

MC3A3.R8.14

Safe

67

70

71

MC3A3.R8.10

Safe

71

72

MC3A3.R17.9

Safe

72

73

MC3A3.R1.3

Exact

73

74

MC3A3.R8.15

Exact

68

74

75

MC3A3.R1.3

Exact

69

75

76

MC3A3.R18.8

Safe

70

76

77

MC3A3.R18.8

Safe

71

77

78

MC3A3.R17.6

Safe

72

78

79

MC3A3.R1.3

Exact

73

79

80

MC3A3.R8.2
MC3A3.R11.1

Safe

74

80

81

MC3A3.R1.3

Unsupported

75

81

82

MC3A3.R1.3

Exact

42

MC3A3.R9.2

Safe

76

82

83

MC3A3.R9.2

Safe

77

83

84

MC3A3.R9.2

Safe

44

78

84

85

MC3A3.R8.6

Exact

79

85

86

MC3A3.R8.2

Safe

80

86

87

MC3A3.R1.3

Exact

45

81

87

88

MC3A3.R17.1

Safe

43

82

88

89

MC3A3.R17.4

Exact

46

83

89

90

MC3A3.R1.3

Exact

91

MC3A3.R1.3

Exact

47

84

90

92

MC3A3.R1.3

Exact

48

85

91

93

MC3A3.R20.3

Exact

86

92

94

MC3A3.R1.3

Unsupported

49

MC3A3.R1.3

Exact

50

87

93

95

MC3A3.R20.6

Exact

51

88

94

96

MC3A3.R20.10

Safe

52

89

95

97

MC3A3.R20.10

Safe

53

90

96

98

MC3A3.R1.3

Exact

91

97

99

MC3A3.R1.3

Exact

92

98

100

MC3A3.R1.3

Exact

54

93

99

101

MC3A3.R21.1

Safe

55

94

100

102

MC3A3.R1.3

Safe

95

101

103

MC3A3.R1.3

Unsupported

56

MC3A3.R17.3
MC3A3.R20.1
MC3A3.R20.4
MC3A3.R21.2

Safe

96

102

104

MC3A3.R20.1

Safe

97

103

105

MC3A3.R20.1
MC3A3.R21.2

Safe

98

104

106

MC3A3.R20.4

Safe

57

MC3A3.R21.1
MC3A3.R21.2

Exact

99

105

107

MC3A3.R21.2

Safe

100

106

108

MC3A3.R21.1
MC3A3.R21.2

Safe

101

107

109

MC3A3.R21.1

Safe

60

102

108

110

MC3A3.D4.11

Best-effort

103

109

111

MC3A3.D4.11
MC3A3.R21.17
MC3A3.R21.18

Best-effort

61

MC3A3.R17.3
MC3A3.R21.2

Safe

62

104

110

112

MC3A3.R1.3

Safe

105

111

113

MC3A3.R1.3

Unsupported

106

112

114

MC3A3.R1.3

Exact

63

107

113

115

MC3A3.D4.11
MC3A3.R21.13

Safe

58

MC3A3.R21.1

Safe

108

114

116

MC3A3.R1.3

Safe

109

115

117

MC3A3.R1.3

Safe

110

116

118

MC3A3.R21.12

Safe

111

117

119

MC3A3.R21.12

Safe

112

118

120

MC3A3.D4.11
MC3A3.R21.12

Safe

90

MC3A3.R21.7

Safe

94

MC3A3.R1.3

Unsupported

113

119

121

MC3A3.R1.3

Unsupported

114

120

122

MC3A3.R21.19

Safe

115

121

123

MC3A3.R21.19

Safe

116

122

124

MC3A3.R21.1
MC3A3.R21.2

Safe

117

123

125

MC3A3.R1.3

Unsupported

64

MC3A3.R21.1
MC3A3.R21.2
MC3A3.R21.4

Safe

118

124

126

MC3A3.R21.1
MC3A3.R21.2
MC3A3.R21.4

Safe

65

119

125

127

MC3A3.R21.4

Safe

120

126

128

MC3A3.R21.4

Safe

66

121

127

129

MC3A3.R21.4

Safe

67

MC3A3.R21.4
MC3A3.R21.5

Safe

122

128

130

MC3A3.R21.5

Safe

123

129

131

MC3A3.R21.5

Safe

130

132

MC3A3.R21.5

Safe

124

131

133

MC3A3.R21.5

Safe

68

MC3A3.R21.5

Safe

125

132

134

MC3A3.R21.5

Safe

69

126

133

135

MC3A3.R21.5

Safe

127

134

136

MC3A3.R21.5

Safe

135

137

MC3A3.R1.3

Safe

128

136

138

MC3A3.R1.3

Safe

70

129

137

139

MC3A3.R17.1

Safe

71

MC3A3.R17.1
MC3A3.R21.1
MC3A3.R21.2

Safe

130

138

140

MC3A3.R17.1
MC3A3.R21.1
MC3A3.R21.2

Safe

75

MC3A3.R17.1

Safe

76

MC3A3.R17.1

Safe

131

139

141

MC3A3.R17.1

Safe

132

140

142

MC3A3.R17.1

Safe

73

MC3A3.R17.1

Safe

74

MC3A3.R17.1

Safe

133

141

143

MC3A3.R17.1

Safe

134

142

144

MC3A3.R17.1

Safe

72

135

143

145

MC3A3.R17.1

Safe

146

MC3A3.R1.3

Safe

59

136

144

147

MC3A3.R1.3

Unsupported

137

145

148

MC3A3.R7.5

Exact

138

146

149

MC3A3.R21.6

Safe

139

147

150

MC3A3.R21.6

Safe

140

148

151

MC3A3.R21.6

Safe

77

141

149

152

MC3A3.R21.6

Safe

142

150

153

MC3A3.R21.6

Safe

78

143

151

154

MC3A3.R21.6

Safe

144

152

155

MC3A3.R21.6

Safe

79

MC3A3.R21.6

Safe

85

MC3A3.R21.6

Safe

145

153

156

MC3A3.R21.6

Safe

146

154

157

MC3A3.R21.6
MC3A3.R21.10

Safe

147

155

158

MC3A3.R21.6

Safe

148

156

159

MC3A3.R21.6

Safe

83

MC3A3.R21.6

Safe

84

MC3A3.R21.6

Safe

149

157

160

MC3A3.R21.6

Safe

82

MC3A3.R21.6

Safe

87

MC3A3.R21.6

Safe

150

158

161

MC3A3.R21.6

Safe

151

159

162

MC3A3.R21.6

Safe

152

160

163

MC3A3.R21.6

Safe

81

153

161

164

MC3A3.R21.6

Safe

97

MC3A3.R21.10

Safe

80

154

162

165

MC3A3.R21.6
MC3A3.R21.10

Safe

86

155

163

166

MC3A3.R21.6

Safe

164

167

MC3A3.R21.6

Safe

89

156

165

168

MC3A3.R21.6

Safe

157

166

169

MC3A3.R21.6

Safe

158

167

170

MC3A3.R21.6

Safe

88

159

168

171

MC3A3.R21.6

Safe

160

169

172

MC3A3.R21.6

Safe

161

170

173

MC3A3.R21.6

Safe

162

171

174

MC3A3.R21.6

Safe

163

172

175

MC3A3.R21.6

Safe

164

173

176

MC3A3.R21.6

Safe

165

174

177

MC3A3.R21.6

Safe

166

175

178

MC3A3.R21.6

Safe

167

176

179

MC3A3.R21.3

Safe

91

168

177

180

MC3A3.R21.3

Safe

178

MC3A3.R21.3

Safe

92

169

179

181

MC3A3.R21.3
MC3A3.R22.2

Safe

170

180

182

MC3A3.R21.3

Safe

171

181

183

MC3A3.R21.3

Safe

93

172

182

184

MC3A3.R21.8

Safe

173

183

185

MC3A3.R21.4

Safe

174

184

186

MC3A3.R21.19

Safe

185

187

MC3A3.R21.5
MC3A3.R21.8

Safe

175

186

188

MC3A3.R21.21

Safe

176

187

189

MC3A3.R21.9

Safe

177

188

190

MC3A3.R21.9

Safe

178

189

191

MC3A3.R21.9

Safe

95

179

190

192

MC3A3.R1.3

Unsupported

96

180

191

193

MC3A3.D4.11
MC3A3.R21.17
MC3A3.R21.18

Best-effort

181

192

194

MC3A3.D4.11
MC3A3.R21.18

Best-effort

182

193

195

MC3A3.R1.3

Unsupported

183

194

196

MC3A3.D4.11

Unsupported

184

195

197

MC3A3.R21.11
MC3A3.R21.22

Safe

185

196

198

MC3A3.R21.11

Safe

199

MC3A3.R1.3

Unsupported

200

MC3A3.R1.3

Unsupported

201

MC3A3.R1.3

Unsupported

202

MC3A3.R1.3

Unsupported

203

MC3A3.R1.3

Unsupported

204

MC3A3.R1.3

Unsupported

197

205

MC3A3.R21.10

Safe

186

198

206

MC3A3.R21.6

Safe

187

199

207

MC3A3.D4.11

Unsupported

188

200

208

MC3A3.R1.3

Unsupported

189

201

209

MC3A3.D4.11

Best-effort

190

202

210

MC3A3.R1.3

Unsupported

191

203

211

MC3A3.R1.3

Unsupported

MISRA C:2012 Amendment 3 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 Amendment 3 coding standard [55].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 Amendment 3 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3A3.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3A3.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3A3.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3A3.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3A3.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3A3.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3A3.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3A3.D4.6

Dir 4.7
Required

no violation report for MC3A3.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3A3.D4.8

Dir 4.9
Advisory

no violation report for MC3A3.D4.9

Dir 4.10
Required

no violation report for MC3A3.D4.10

Dir 4.11
Required

no violation report for MC3A3.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3A3.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3A3.D4.13

Dir 4.14
Required

no violation report for MC3A3.D4.14

after: ensure that the external program input is adequately sanitized before use

Dir 4.15
Required

no violation report or caution report for MC3A3.D4.15

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3A3.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3A3.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table is reported with the indicated precision.;
after: nothing to do

Rule 1.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R1.4

Rule 1.5
Required
Undecidable
System

no violation report or caution report for MC3A3.R1.5

Rule 2.1
Required
Undecidable
System

no violation report for MC3A3.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3A3.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3A3.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3A3.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3A3.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R2.7

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3A3.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3A3.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3A3.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3A3.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3A3.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3A3.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R6.2

Rule 6.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R6.3

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A3.R7.4

Rule 7.5
Mandatory
Decidable
Single T.U.

no violation report for MC3A3.R7.5

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3A3.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3A3.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3A3.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3A3.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3A3.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3A3.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3A3.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3A3.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3A3.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3A3.R8.14

Rule 8.15
Required
Decidable
System

no violation report for MC3A3.R8.15

Rule 8.16
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R8.16

Rule 8.17
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R8.17

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A3.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3A3.R9.5

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3A3.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3A3.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3A3.R11.9

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3A3.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3A3.R12.5

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3A3.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3A3.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3A3.R13.5

Rule 13.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3A3.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3A3.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3A3.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3A3.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3A3.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3A3.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3A3.R17.4

Rule 17.5
Required
Undecidable
System

no violation report or caution report for MC3A3.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3A3.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3A3.R17.8

Rule 17.9
Mandatory
Undecidable
System

no violation report for MC3A3.R17.9

Rule 17.10
Required
Decidable
Single T.U.

no violation report for MC3A3.R17.10

Rule 17.11
Advisory
Undecidable
System

no violation report for MC3A3.R17.11

after: obtain 100% return point coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 17.12
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R17.12

Rule 17.13
Required
Decidable
Single T.U.

no violation report for MC3A3.R17.13

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3A3.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3A3.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3A3.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3A3.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3A3.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3A3.R18.8

Rule 18.9
Required
Decidable
Single T.U.

no violation report for MC3A3.R18.9

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3A3.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3A3.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.10

Rule 21.11
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R21.11

Rule 21.12
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3A3.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R21.20

Rule 21.21
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.21

Rule 21.22
Mandatory
Decidable
Single T.U.

no violation report for MC3A3.R21.22

Rule 21.23
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.23

Rule 21.24
Required
Decidable
Single T.U.

no violation report for MC3A3.R21.24

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3A3.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3A3.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3A3.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3A3.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3A3.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3A3.R22.10

Rule 23.1
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R23.1

Rule 23.2
Required
Decidable
Single T.U.

no violation report for MC3A3.R23.2

Rule 23.3
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R23.3

Rule 23.4
Required
Decidable
Single T.U.

no violation report for MC3A3.R23.4

Rule 23.5
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R23.5

Rule 23.6
Required
Decidable
Single T.U.

no violation report for MC3A3.R23.6

Rule 23.7
Advisory
Decidable
Single T.U.

no violation report for MC3A3.R23.7

Rule 23.8
Required
Decidable
Single T.U.

no violation report for MC3A3.R23.8

MISRA C:2012 Amendment 4 Additional Information

This section contains the following additional information related to the support of the MISRA C coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2012 Amendment 4 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2012 Amendment 4 coding standard [57].

For all guidelines, the mapping between the MISRA C:2012 Amendment 4 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2012 Amendment 4 Directive 1.1 maps to ECLAIR service MC3A4.D1.1,

  • MISRA C:2012 Amendment 4 Rule 1.2 maps to ECLAIR service MC3A4.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3A4 synopsis: supported MISRA C:2012 Amendment 4 guidelines

Id

Headline

Precision

MC3A4.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3A4.D2.1

All source files shall compile without any compilation errors

Process

MC3A4.D3.1

All code shall be traceable to documented requirements

Process

MC3A4.D4.1

Run-time failures shall be minimized

Process

MC3A4.D4.2

All usage of assembly language should be documented

Process

MC3A4.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3A4.D4.4

Sections of code should not be “commented out”

Heuristic

MC3A4.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3A4.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3A4.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3A4.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3A4.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3A4.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3A4.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3A4.D4.12

Dynamic memory allocation shall not be used

Process

MC3A4.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3A4.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3A4.D4.15

Evaluation of floating-point expressions shall not lead to the undetected generation of infinities and NaNs

Complete

MC3A4.D5.1

There shall be no data races between threads

Safe

MC3A4.D5.2

There shall be no deadlocks between threads

Process

MC3A4.D5.3

There shall be no dynamic thread creation

Safe

MC3A4.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3A4.R1.2

Language extensions should not be used

Safe

MC3A4.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3A4.R1.4

Emergent language features shall not be used

Exact

MC3A4.R1.5

Obsolescent language features shall not be used

Complete

MC3A4.R2.1

A project shall not contain unreachable code

Best-effort

MC3A4.R2.2

A project shall not contain dead code

Best-effort

MC3A4.R2.3

A project should not contain unused type declarations

Exact

MC3A4.R2.4

A project should not contain unused tag declarations

Exact

MC3A4.R2.5

A project should not contain unused macro definitions

Exact

MC3A4.R2.6

A function should not contain unused label declarations

Exact

MC3A4.R2.7

A function should not contain unused parameters

Exact

MC3A4.R2.8

A project should not contain unused object definitions

Exact

MC3A4.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3A4.R3.2

Line-splicing shall not be used in // comments

Exact

MC3A4.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3A4.R4.2

Trigraphs should not be used

Exact

MC3A4.R5.1

External identifiers shall be distinct

Exact

MC3A4.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3A4.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3A4.R5.4

Macro identifiers shall be distinct

Exact

MC3A4.R5.5

Identifiers shall be distinct from macro names

Exact

MC3A4.R5.6

A typedef name shall be a unique identifier

Exact

MC3A4.R5.7

A tag name shall be a unique identifier

Exact

MC3A4.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3A4.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3A4.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3A4.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3A4.R6.3

A bit field shall not be declared as a member of a union

Exact

MC3A4.R7.1

Octal constants shall not be used

Exact

MC3A4.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3A4.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3A4.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3A4.R7.5

The argument of an integer constant macro shall have an appropriate form

Exact

MC3A4.R7.6

The small integer variants of the minimum-width integer constant macros shall not be used

Exact

MC3A4.R8.1

Types shall be explicitly specified

Exact

MC3A4.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3A4.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3A4.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3A4.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3A4.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3A4.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3A4.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3A4.R8.9

An object should be declared at block scope if its identifier only appears in a single function

Exact

MC3A4.R8.10

An inline function shall be declared with the static storage class

Exact

MC3A4.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3A4.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3A4.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3A4.R8.14

The restrict type qualifier shall not be used

Exact

MC3A4.R8.15

All declarations of an object with an explicit alignment specification shall specify the same alignment

Exact

MC3A4.R8.16

The alignment specification of zero should not appear in an object declaration

Exact

MC3A4.R8.17

At most one explicit alignment specifier should appear in an object declaration

Exact

MC3A4.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3A4.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3A4.R9.3

Arrays shall not be partially initialized

Exact

MC3A4.R9.4

An element of an object shall not be initialized more than once

Complete

MC3A4.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3A4.R9.6

An initializer using chained designators shall not contain initializers without designators

Exact

MC3A4.R9.7

Atomic objects shall be appropriately initialized before being accessed

Safe

MC3A4.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3A4.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3A4.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3A4.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3A4.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3A4.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3A4.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3A4.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3A4.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3A4.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3A4.R11.3

A conversion shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3A4.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3A4.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3A4.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3A4.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3A4.R11.8

A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer

Exact

MC3A4.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3A4.R11.10

The _Atomic qualifier shall not be applied to the incomplete type void

Exact

MC3A4.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3A4.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3A4.R12.3

The comma operator should not be used

Exact

MC3A4.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3A4.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3A4.R12.6

Structure and union members of atomic objects shall not be directly accessed

Exact

MC3A4.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3A4.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving

Safe

MC3A4.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3A4.R13.4

The result of an assignment operator should not be used

Exact

MC3A4.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3A4.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3A4.R14.1

A loop counter shall not have essentially floating type

Safe

MC3A4.R14.2

A for loop shall be well-formed

Safe

MC3A4.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3A4.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3A4.R15.1

The goto statement should not be used

Exact

MC3A4.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3A4.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3A4.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3A4.R15.5

A function should have a single point of exit at the end

Exact

MC3A4.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3A4.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3A4.R16.1

All switch statements shall be well-formed

Exact

MC3A4.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3A4.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3A4.R16.4

Every switch statement shall have a default label

Exact

MC3A4.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3A4.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3A4.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3A4.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3A4.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3A4.R17.3

A function shall not be declared implicitly

Exact

MC3A4.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3A4.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3A4.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3A4.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3A4.R17.8

A function parameter should not be modified

Precise

MC3A4.R17.9

A function declared with a _Noreturn function specifier shall not return to its caller

Precise

MC3A4.R17.10

A function declared with a _Noreturn function specifier shall have * void* return type

Exact

MC3A4.R17.11

A function that never returns should be declared with a _Noreturn function specifier

Best-effort

MC3A4.R17.12

A function identifier should only be used with either a preceding &, or with a parenthesized parameter list

Exact

MC3A4.R17.13

A function type shall not be type qualified

Exact

MC3A4.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3A4.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3A4.R18.3

The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object

Safe

MC3A4.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3A4.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3A4.R18.6

The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3A4.R18.7

Flexible array members shall not be declared

Exact

MC3A4.R18.8

Variable-length arrays shall not be used

Exact

MC3A4.R18.9

An object with temporary lifetime shall not undergo array-to-pointer conversion

Exact

MC3A4.R18.10

Pointers to variably-modified array types shall not be used

Exact

MC3A4.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3A4.R19.2

The union keyword should not be used

Exact

MC3A4.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3A4.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3A4.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3A4.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3A4.R20.5

#undef should not be used

Exact

MC3A4.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3A4.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3A4.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3A4.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3A4.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3A4.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3A4.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3A4.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3A4.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3A4.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3A4.R21.2

A reserved identifier or reserved macro name shall not be declared

Exact

MC3A4.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3A4.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3A4.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3A4.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3A4.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3A4.R21.8

The Standard Library termination functions of <stdlib.h> shall not be used

Exact

MC3A4.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3A4.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3A4.R21.11

The standard header file <tgmath.h> should not be used

Exact

MC3A4.R21.12

The standard header file <fenv.h> shall not be used

Exact

MC3A4.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3A4.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3A4.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3A4.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3A4.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3A4.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3A4.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3A4.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3A4.R21.21

The Standard Library function system of <stdlib.h> shall not be used

Exact

MC3A4.R21.22

All operand arguments to any type-generic macros declared in <tgmath.h> shall have an appropriate essential type

Exact

MC3A4.R21.23

All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type

Exact

MC3A4.R21.24

The random number generator functions of <stdlib.h> shall not be used

Exact

MC3A4.R21.25

All memory synchronization operations shall be executed in sequentially consistent order

Safe

MC3A4.R21.26

The Standard Library function mtx_timedlock() shall only be invoked on mutex objects of appropriate mutex type

Complete

MC3A4.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3A4.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3A4.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3A4.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3A4.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3A4.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3A4.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3A4.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3A4.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3A4.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

MC3A4.R22.11

A thread that was previously either joined or detached shall not be subsequently joined nor detached

Safe

MC3A4.R22.12

Thread objects, thread synchronization objects, and thread-specific storage pointers shall only be accessed by the appropriate Standard Library functions

Safe

MC3A4.R22.13

Thread objects, thread synchronization objects and thread-specific storage pointers shall have appropriate storage duration

Exact

MC3A4.R22.14

Thread synchronization objects shall be initialized before being accessed

Safe

MC3A4.R22.15

Thread synchronization objects and thread-specific storage pointers shall not be destroyed until after all threads accessing them have terminated

Safe

MC3A4.R22.16

All mutex objects locked by a thread shall be explicitly unlocked by the same thread

Safe

MC3A4.R22.17

No thread shall unlock a mutex or call cnd_wait() or cnd_timedwait() for a mutex it has not locked before

Safe

MC3A4.R22.18

Non-recursive mutexes shall not be recursively locked

Safe

MC3A4.R22.19

A condition variable shall be associated with at most one mutex object

Safe

MC3A4.R22.20

Thread-specific storage pointers shall be created before being accessed

Safe

MC3A4.R23.1

A generic selection should only be expanded from a macro

Exact

MC3A4.R23.2

A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression

Exact

MC3A4.R23.3

A generic selection should contain at least one non-default association

Exact

MC3A4.R23.4

A generic association shall list an appropriate type

Exact

MC3A4.R23.5

A generic selection should not depend on implicit pointer type conversion

Exact

MC3A4.R23.6

The controlling expression of a generic selection shall have an essential type that matches its standard type

Exact

MC3A4.R23.7

A generic selection that is expanded from a macro should evaluate its argument only once

Exact

MC3A4.R23.8

A default association shall appear as either the first or the last association of a generic selection

Exact

Coverage of Undefined Behaviours for MISRA C:2012 Amendment 4

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [57]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3A4.R1.3

Exact

2

MC3A4.R1.3

Exact

3

MC3A4.R20.10

Unsupported

3

3

3

MC3A4.R1.3

Exact

4

4

4

MC3A4.R1.3

Exact

5

5

MC3A4.D5.1
MC3A4.R9.7

Safe

5

6

6

MC3A4.R1.3

Exact

6

7

7

MC3A4.R1.3

Unsupported

5

MC3A4.R5.2

Exact

6

MC3A4.R17.3

Exact

8

7

8

8

MC3A4.R1.3

Exact

8

9

9

MC3A4.D4.12
MC3A4.R18.6
MC3A4.R18.9
MC3A4.R21.3
MC3A4.R22.13
MC3A4.R22.14
MC3A4.R22.15
MC3A4.R22.20

Safe

9

MC3A4.D4.12
MC3A4.R18.6
MC3A4.R21.3

Safe

9

10

10

MC3A4.D4.12
MC3A4.R18.6
MC3A4.R21.3
MC3A4.R22.15

Safe

10

11

11

MC3A4.R22.13

Safe

11

12

12

MC3A4.R1.3

Unsupported

12

13

13

MC3A4.R11.2
MC3A4.R11.3
MC3A4.R11.4
MC3A4.R11.5

Safe

13

14

14

MC3A4.R1.3

Unsupported

10

14

15

15

MC3A4.R5.6
MC3A4.R5.7
MC3A4.R8.3

Safe

15

MC3A4.D4.1
MC3A4.D4.14
MC3A4.R10.3

Process

16

16

MC3A4.R18.8

Safe

15

17

17

MC3A4.D4.1
MC3A4.D4.14
MC3A4.R10.3

Process

16

18

18

MC3A4.D4.1
MC3A4.D4.14
MC3A4.R10.3

Process

17

19

19

MC3A4.R9.1
MC3A4.R11.2
MC3A4.R11.3
MC3A4.R11.4
MC3A4.R11.5
MC3A4.R19.1

Process

16

18

20

20

MC3A4.R1.3

Exact

21

21

MC3A4.R1.3

Safe

19

22

22

MC3A4.R1.3

Exact

17

20

23

23

MC3A4.R1.3

Exact

21

24

24

MC3A4.R11.1
MC3A4.R11.2
MC3A4.R11.4
MC3A4.R11.6

Safe

22

25

25

MC3A4.R11.2
MC3A4.R11.3
MC3A4.R11.5

Safe

27

23

26

26

MC3A4.R11.1

Safe

4

24

27

27

MC3A4.R1.3

Exact

25

28

28

MC3A4.R1.3

Exact

26

29

29

MC3A4.R1.3

Exact

27

30

30

MC3A4.R1.3

Exact

7

28

31

31

MC3A4.R5.1
MC3A4.R5.2
MC3A4.R5.3
MC3A4.R5.4
MC3A4.R5.5

Exact

29

32

32

MC3A4.R21.2

Exact

11

MC3A4.R1.3

Exact

12

30

33

33

MC3A4.R7.4
MC3A4.R11.4
MC3A4.R11.8

Safe

13

MC3A4.R1.3

Exact

14

MC3A4.R20.2

Exact

31

34

34

MC3A4.R20.2

Exact

18

32

35

35

MC3A4.R13.2
MC3A4.R13.3
MC3A4.R13.4

Safe

19

33

36

36

MC3A4.D4.1
MC3A4.D4.14

Process

20

MC3A4.R11.3
MC3A4.R11.4
MC3A4.R11.5

Safe

34

37

37

MC3A4.R11.3
MC3A4.R11.4
MC3A4.R11.5

Safe

35

MC3A4.R18.9

Safe

21

MC3A4.R1.3

Exact

22

36

38

38

MC3A4.R8.2
MC3A4.R17.3

Safe

23

MC3A4.R8.2
MC3A4.R17.3

Safe

24

MC3A4.R5.6
MC3A4.R5.7
MC3A4.R8.3
MC3A4.R8.4
MC3A4.R8.5
MC3A4.R11.1
MC3A4.R21.2

Safe

25

MC3A4.R8.4
MC3A4.R8.5
MC3A4.R11.1
MC3A4.R21.2
MC3A4.R17.3

Safe

37

39

39

MC3A4.R8.4
MC3A4.R8.5
MC3A4.R11.1
MC3A4.R21.2
MC3A4.R17.3

Safe

38

40

40

MC3A4.R8.2

Safe

39

41

41

MC3A4.R5.6
MC3A4.R5.7
MC3A4.R8.2
MC3A4.R8.3
MC3A4.R8.4
MC3A4.R8.5
MC3A4.R11.1
MC3A4.R21.2

Safe

42

42

MC3A4.R12.6

Exact

26

40

43

43

MC3A4.D4.1
MC3A4.D4.14

Process

28

MC3A4.R11.1

Exact

29

41

44

44

MC3A4.R11.1
MC3A4.R11.2
MC3A4.R11.6
MC3A4.R11.7

Exact

42

45

45

MC3A4.D4.1

Process

46

MC3A4.R1.3

Process

30

43

46

47

MC3A4.D4.14
MC3A4.R18.1

Best-effort

44

47

48

MC3A4.D4.14
MC3A4.R18.1

Best-effort

31

45

48

49

MC3A4.D4.14
MC3A4.R18.2

Best-effort

46

49

50

MC3A4.R18.1

Best-effort

47

50

51

MC3A4.R1.3

Process

32

48

51

52

MC3A4.D4.14
MC3A4.R10.1
MC3A4.R12.2

Safe

49

52

53

MC3A4.R1.3

Unsupported

33

50

53

54

MC3A4.R18.3

Best-effort

34

51

54

55

MC3A4.R19.1

Best-effort

52

55

56

MC3A4.R1.3

Exact

53

56

57

MC3A4.R1.3

Exact

54

57

58

MC3A4.R1.3

Exact

55

58

59

MC3A4.R1.3

Unsupported

35

56

59

60

MC3A4.R1.3

Exact

36

57

60

61

MC3A4.R1.3

Exact

37

58

61

62

MC3A4.R1.3

Exact

38

MC3A4.R6.1

Exact

59

62

63

MC3A4.R18.7

Safe

60

63

64

MC3A4.R1.3

Exact

39

61

64

65

MC3A4.R11.4
MC3A4.R11.8
MC3A4.R19.2

Safe

40

62

65

66

MC3A4.R11.4
MC3A4.R11.8
MC3A4.R19.2

Safe

41

MC3A4.R9.1

Safe

63

66

67

MC3A4.R17.13

Exact

64

67

68

MC3A4.R1.3

Exact

65

68

69

MC3A4.R8.14

Safe

66

69

70

MC3A4.R8.14

Safe

67

70

71

MC3A4.R8.10

Safe

71

72

MC3A4.R17.9

Safe

72

73

MC3A4.R1.3

Exact

73

74

MC3A4.R8.15

Exact

68

74

75

MC3A4.R1.3

Exact

69

75

76

MC3A4.R18.10

Safe

70

76

77

MC3A4.R18.10

Safe

71

77

78

MC3A4.R17.6

Safe

72

78

79

MC3A4.R1.3

Exact

73

79

80

MC3A4.R8.2
MC3A4.R11.1

Safe

74

80

81

MC3A4.R1.3

Unsupported

75

81

82

MC3A4.R1.3

Exact

42

MC3A4.R9.2

Safe

76

82

83

MC3A4.R9.2

Safe

77

83

84

MC3A4.R9.2

Safe

44

78

84

85

MC3A4.R8.6

Exact

79

85

86

MC3A4.R8.2

Safe

80

86

87

MC3A4.R1.3

Exact

45

81

87

88

MC3A4.R17.1

Safe

43

82

88

89

MC3A4.R17.4

Exact

46

83

89

90

MC3A4.R1.3

Exact

91

MC3A4.R1.3

Exact

47

84

90

92

MC3A4.R1.3

Exact

48

85

91

93

MC3A4.R20.3

Exact

86

92

94

MC3A4.R1.3

Unsupported

49

MC3A4.R1.3

Exact

50

87

93

95

MC3A4.R20.6

Exact

51

88

94

96

MC3A4.R20.10

Safe

52

89

95

97

MC3A4.R20.10

Safe

53

90

96

98

MC3A4.R1.3

Exact

91

97

99

MC3A4.R1.3

Exact

92

98

100

MC3A4.R1.3

Exact

54

93

99

101

MC3A4.R21.1

Safe

55

94

100

102

MC3A4.R1.3

Safe

95

101

103

MC3A4.R1.3

Unsupported

56

MC3A4.R17.3
MC3A4.R20.1
MC3A4.R20.4
MC3A4.R21.2

Safe

96

102

104

MC3A4.R20.1

Safe

97

103

105

MC3A4.R20.1
MC3A4.R21.2

Safe

98

104

106

MC3A4.R20.4

Safe

57

MC3A4.R21.1
MC3A4.R21.2

Exact

99

105

107

MC3A4.R21.2

Safe

100

106

108

MC3A4.R21.1
MC3A4.R21.2

Safe

101

107

109

MC3A4.R21.1

Safe

60

102

108

110

MC3A4.D4.11

Best-effort

103

109

111

MC3A4.D4.11
MC3A4.R21.17
MC3A4.R21.18

Best-effort

61

MC3A4.R17.3
MC3A4.R21.2

Safe

62

104

110

112

MC3A4.R1.3

Safe

105

111

113

MC3A4.R1.3

Unsupported

106

112

114

MC3A4.R1.3

Exact

63

107

113

115

MC3A4.D4.11
MC3A4.R21.13

Safe

58

MC3A4.R21.1

Safe

108

114

116

MC3A4.R1.3

Safe

109

115

117

MC3A4.R1.3

Safe

110

116

118

MC3A4.R21.12

Safe

111

117

119

MC3A4.R21.12

Safe

112

118

120

MC3A4.D4.11
MC3A4.R21.12

Safe

90

MC3A4.R21.7

Safe

94

MC3A4.R1.3

Unsupported

113

119

121

MC3A4.R1.3

Unsupported

114

120

122

MC3A4.R21.19

Safe

115

121

123

MC3A4.R21.19

Safe

116

122

124

MC3A4.R21.1
MC3A4.R21.2

Safe

117

123

125

MC3A4.R1.3

Unsupported

64

MC3A4.R21.1
MC3A4.R21.2
MC3A4.R21.4

Safe

118

124

126

MC3A4.R21.1
MC3A4.R21.2
MC3A4.R21.4

Safe

65

119

125

127

MC3A4.R21.4

Safe

120

126

128

MC3A4.R21.4

Safe

66

121

127

129

MC3A4.R21.4

Safe

67

MC3A4.R21.4
MC3A4.R21.5

Safe

122

128

130

MC3A4.R21.5

Safe

123

129

131

MC3A4.R21.5

Safe

130

132

MC3A4.R21.5

Safe

124

131

133

MC3A4.R21.5

Safe

68

MC3A4.R21.5

Safe

125

132

134

MC3A4.R21.5

Safe

69

126

133

135

MC3A4.R21.5

Safe

127

134

136

MC3A4.R21.5

Safe

135

137

MC3A4.R1.3

Safe

128

136

138

MC3A4.R1.3

Safe

70

129

137

139

MC3A4.R17.1

Safe

71

MC3A4.R17.1
MC3A4.R21.1
MC3A4.R21.2

Safe

130

138

140

MC3A4.R17.1
MC3A4.R21.1
MC3A4.R21.2

Safe

75

MC3A4.R17.1

Safe

76

MC3A4.R17.1

Safe

131

139

141

MC3A4.R17.1

Safe

132

140

142

MC3A4.R17.1

Safe

73

MC3A4.R17.1

Safe

74

MC3A4.R17.1

Safe

133

141

143

MC3A4.R17.1

Safe

134

142

144

MC3A4.R17.1

Safe

72

135

143

145

MC3A4.R17.1

Safe

146

MC3A4.R1.3

Safe

59

136

144

147

MC3A4.R1.3

Unsupported

137

145

148

MC3A4.R7.5

Exact

138

146

149

MC3A4.R21.6

Safe

139

147

150

MC3A4.R21.6

Safe

140

148

151

MC3A4.R21.6

Safe

77

141

149

152

MC3A4.R21.6

Safe

142

150

153

MC3A4.R21.6

Safe

78

143

151

154

MC3A4.R21.6

Safe

144

152

155

MC3A4.R21.6

Safe

79

MC3A4.R21.6

Safe

85

MC3A4.R21.6

Safe

145

153

156

MC3A4.R21.6

Safe

146

154

157

MC3A4.R21.6
MC3A4.R21.10

Safe

147

155

158

MC3A4.R21.6

Safe

148

156

159

MC3A4.R21.6

Safe

83

MC3A4.R21.6

Safe

84

MC3A4.R21.6

Safe

149

157

160

MC3A4.R21.6

Safe

82

MC3A4.R21.6

Safe

87

MC3A4.R21.6

Safe

150

158

161

MC3A4.R21.6

Safe

151

159

162

MC3A4.R21.6

Safe

152

160

163

MC3A4.R21.6

Safe

81

153

161

164

MC3A4.R21.6

Safe

97

MC3A4.R21.10

Safe

80

154

162

165

MC3A4.R21.6
MC3A4.R21.10

Safe

86

155

163

166

MC3A4.R21.6

Safe

164

167

MC3A4.R21.6

Safe

89

156

165

168

MC3A4.R21.6

Safe

157

166

169

MC3A4.R21.6

Safe

158

167

170

MC3A4.R21.6

Safe

88

159

168

171

MC3A4.R21.6

Safe

160

169

172

MC3A4.R21.6

Safe

161

170

173

MC3A4.R21.6

Safe

162

171

174

MC3A4.R21.6

Safe

163

172

175

MC3A4.R21.6

Safe

164

173

176

MC3A4.R21.6

Safe

165

174

177

MC3A4.R21.6

Safe

166

175

178

MC3A4.R21.6

Safe

167

176

179

MC3A4.R21.3

Safe

91

168

177

180

MC3A4.R21.3

Safe

178

MC3A4.R21.3

Safe

92

169

179

181

MC3A4.R21.3
MC3A4.R22.2

Safe

170

180

182

MC3A4.R21.3

Safe

171

181

183

MC3A4.R21.3

Safe

93

172

182

184

MC3A4.R21.8

Safe

173

183

185

MC3A4.R21.4

Safe

174

184

186

MC3A4.R21.19

Safe

185

187

MC3A4.R21.5
MC3A4.R21.8

Safe

175

186

188

MC3A4.R21.21

Safe

176

187

189

MC3A4.R21.9

Safe

177

188

190

MC3A4.R21.9

Safe

178

189

191

MC3A4.R21.9

Safe

95

179

190

192

MC3A4.R1.3

Unsupported

96

180

191

193

MC3A4.D4.11
MC3A4.R21.17
MC3A4.R21.18

Best-effort

181

192

194

MC3A4.D4.11
MC3A4.R21.18

Best-effort

182

193

195

MC3A4.R1.3

Unsupported

183

194

196

MC3A4.D4.11

Unsupported

184

195

197

MC3A4.R21.11
MC3A4.R21.22

Safe

185

196

198

MC3A4.R21.11

Safe

199

MC3A4.R1.3

Unsupported

200

MC3A4.R1.3

Unsupported

201

MC3A4.R1.3

Unsupported

202

MC3A4.R1.3

Unsupported

203

MC3A4.R1.3

Unsupported

204

MC3A4.R1.3

Unsupported

197

205

MC3A4.R21.10

Safe

186

198

206

MC3A4.R21.6

Safe

187

199

207

MC3A4.D4.11

Unsupported

188

200

208

MC3A4.R1.3

Unsupported

189

201

209

MC3A4.D4.11

Best-effort

190

202

210

MC3A4.R1.3

Unsupported

191

203

211

MC3A4.R1.3

Unsupported

MISRA C:2012 Amendment 4 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2012 Amendment 4 coding standard [57].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2012 Amendment 4 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3A4.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3A4.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3A4.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3A4.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3A4.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3A4.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3A4.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3A4.D4.6

Dir 4.7
Required

no violation report for MC3A4.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3A4.D4.8

Dir 4.9
Advisory

no violation report for MC3A4.D4.9

Dir 4.10
Required

no violation report for MC3A4.D4.10

Dir 4.11
Required

no violation report for MC3A4.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3A4.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3A4.D4.13

Dir 4.14
Required

no violation report for MC3A4.D4.14

after: ensure that the external program input is adequately sanitized before use

Dir 4.15
Required

no violation report or caution report for MC3A4.D4.15

Dir 5.1
Required

no violation report for MC3A4.D5.1

Dir 5.2
Required

no violation report for MC3A4.D5.2

before: Manually verify that no deadlocks are possible, given all the possible resource allocation patterns present in the program;
after: Perform dynamic testing on the program to gain confidence on the absence of deadlocks

Dir 5.3
Required

no violation report for MC3A4.D5.3

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3A4.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3A4.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table is reported with the indicated precision.;
after: nothing to do

Rule 1.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R1.4

Rule 1.5
Required
Undecidable
System

no violation report or caution report for MC3A4.R1.5

Rule 2.1
Required
Undecidable
System

no violation report for MC3A4.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3A4.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3A4.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3A4.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3A4.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R2.7

Rule 2.8
Advisory
Decidable
System

no violation report for MC3A4.R2.8

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3A4.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3A4.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3A4.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3A4.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3A4.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3A4.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R6.2

Rule 6.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R6.3

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A4.R7.4

Rule 7.5
Mandatory
Decidable
Single T.U.

no violation report for MC3A4.R7.5

Rule 7.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R7.6

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3A4.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3A4.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3A4.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3A4.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3A4.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3A4.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3A4.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3A4.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3A4.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3A4.R8.14

Rule 8.15
Required
Decidable
System

no violation report for MC3A4.R8.15

Rule 8.16
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R8.16

Rule 8.17
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R8.17

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3A4.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3A4.R9.5

Rule 9.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R9.6

Rule 9.7
Mandatory
Undecidable
System

no violation report for MC3A4.R9.7

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3A4.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.9

Rule 11.10
Required
Decidable
Single T.U.

no violation report for MC3A4.R11.10

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3A4.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3A4.R12.5

Rule 12.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R12.6

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3A4.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3A4.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3A4.R13.5

Rule 13.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3A4.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3A4.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3A4.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3A4.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3A4.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3A4.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3A4.R17.4

Rule 17.5
Required
Undecidable
System

no violation report or caution report for MC3A4.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3A4.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3A4.R17.8

Rule 17.9
Mandatory
Undecidable
System

no violation report for MC3A4.R17.9

Rule 17.10
Required
Decidable
Single T.U.

no violation report for MC3A4.R17.10

Rule 17.11
Advisory
Undecidable
System

no violation report for MC3A4.R17.11

after: obtain 100% return point coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 17.12
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R17.12

Rule 17.13
Required
Decidable
Single T.U.

no violation report for MC3A4.R17.13

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3A4.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3A4.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3A4.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3A4.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3A4.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3A4.R18.8

Rule 18.9
Required
Decidable
Single T.U.

no violation report for MC3A4.R18.9

Rule 18.10
Mandatory
Decidable
Single T.U.

no violation report for MC3A4.R18.10

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3A4.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3A4.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.10

Rule 21.11
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R21.11

Rule 21.12
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3A4.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R21.20

Rule 21.21
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.21

Rule 21.22
Mandatory
Decidable
Single T.U.

no violation report for MC3A4.R21.22

Rule 21.23
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.23

Rule 21.24
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.24

Rule 21.25
Required
Decidable
Single T.U.

no violation report for MC3A4.R21.25

Rule 21.26
Required
Undecidable
System

no violation report for MC3A4.R21.26

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3A4.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3A4.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3A4.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3A4.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3A4.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3A4.R22.10

Rule 22.11
Required
Undecidable
System

no violation report for MC3A4.R22.11

Rule 22.12
Mandatory
Undecidable
System

no violation report for MC3A4.R22.12

Rule 22.13
Required
Decidable
Single T.U.

no violation report for MC3A4.R22.13

Rule 22.14
Mandatory
Undecidable
System

no violation report for MC3A4.R22.14

Rule 22.15
Required
Undecidable
System

no violation report for MC3A4.R22.15

Rule 22.16
Required
Undecidable
System

no violation report for MC3A4.R22.16

Rule 22.17
Required
Undecidable
System

no violation report for MC3A4.R22.17

Rule 22.18
Required
Undecidable
System

no violation report for MC3A4.R22.18

Rule 22.19
Required
Undecidable
System

no violation report for MC3A4.R22.19

Rule 22.20
Mandatory
Undecidable
System

no violation report for MC3A4.R22.20

Rule 23.1
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R23.1

Rule 23.2
Required
Decidable
Single T.U.

no violation report for MC3A4.R23.2

Rule 23.3
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R23.3

Rule 23.4
Required
Decidable
Single T.U.

no violation report for MC3A4.R23.4

Rule 23.5
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R23.5

Rule 23.6
Required
Decidable
Single T.U.

no violation report for MC3A4.R23.6

Rule 23.7
Advisory
Decidable
Single T.U.

no violation report for MC3A4.R23.7

Rule 23.8
Required
Decidable
Single T.U.

no violation report for MC3A4.R23.8

MISRA C:2023 Additional Information

This section contains the following additional information related to the support of the MISRA C coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2023 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2023 coding standard [58].

For all guidelines, the mapping between the MISRA C:2023 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2023 Directive 1.1 maps to ECLAIR service MC3R2.D1.1,

  • MISRA C:2023 Rule 1.2 maps to ECLAIR service MC3R2.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC3R2 synopsis: supported MISRA C:2023 guidelines

Id

Headline

Precision

MC3R2.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC3R2.D2.1

All source files shall compile without any compilation errors

Process

MC3R2.D3.1

All code shall be traceable to documented requirements

Process

MC3R2.D4.1

Run-time failures shall be minimized

Process

MC3R2.D4.2

All usage of assembly language should be documented

Process

MC3R2.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC3R2.D4.4

Sections of code should not be “commented out”

Heuristic

MC3R2.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC3R2.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC3R2.D4.7

If a function returns error information, then that error information shall be tested

Process

MC3R2.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC3R2.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC3R2.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC3R2.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC3R2.D4.12

Dynamic memory allocation shall not be used

Process

MC3R2.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC3R2.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC3R2.D4.15

Evaluation of floating-point expressions shall not lead to the undetected generation of infinities and NaNs

Complete

MC3R2.D5.1

There shall be no data races between threads

Safe

MC3R2.D5.2

There shall be no deadlocks between threads

Process

MC3R2.D5.3

There shall be no dynamic thread creation

Safe

MC3R2.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC3R2.R1.2

Language extensions should not be used

Safe

MC3R2.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC3R2.R1.4

Emergent language features shall not be used

Exact

MC3R2.R1.5

Obsolescent language features shall not be used

Complete

MC3R2.R2.1

A project shall not contain unreachable code

Best-effort

MC3R2.R2.2

A project shall not contain dead code

Best-effort

MC3R2.R2.3

A project should not contain unused type declarations

Exact

MC3R2.R2.4

A project should not contain unused tag declarations

Exact

MC3R2.R2.5

A project should not contain unused macro definitions

Exact

MC3R2.R2.6

A function should not contain unused label declarations

Exact

MC3R2.R2.7

A function should not contain unused parameters

Exact

MC3R2.R2.8

A project should not contain unused object definitions

Exact

MC3R2.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC3R2.R3.2

Line-splicing shall not be used in // comments

Exact

MC3R2.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC3R2.R4.2

Trigraphs should not be used

Exact

MC3R2.R5.1

External identifiers shall be distinct

Exact

MC3R2.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC3R2.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC3R2.R5.4

Macro identifiers shall be distinct

Exact

MC3R2.R5.5

Identifiers shall be distinct from macro names

Exact

MC3R2.R5.6

A typedef name shall be a unique identifier

Exact

MC3R2.R5.7

A tag name shall be a unique identifier

Exact

MC3R2.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC3R2.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC3R2.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC3R2.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC3R2.R6.3

A bit field shall not be declared as a member of a union

Exact

MC3R2.R7.1

Octal constants shall not be used

Exact

MC3R2.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC3R2.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC3R2.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC3R2.R7.5

The argument of an integer constant macro shall have an appropriate form

Exact

MC3R2.R7.6

The small integer variants of the minimum-width integer constant macros shall not be used

Exact

MC3R2.R8.1

Types shall be explicitly specified

Exact

MC3R2.R8.2

Function types shall be in prototype form with named parameters

Exact

MC3R2.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC3R2.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC3R2.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC3R2.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC3R2.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC3R2.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC3R2.R8.9

An object should be declared at block scope if its identifier only appears in a single function

Exact

MC3R2.R8.10

An inline function shall be declared with the static storage class

Exact

MC3R2.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC3R2.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC3R2.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC3R2.R8.14

The restrict type qualifier shall not be used

Exact

MC3R2.R8.15

All declarations of an object with an explicit alignment specification shall specify the same alignment

Exact

MC3R2.R8.16

The alignment specification of zero should not appear in an object declaration

Exact

MC3R2.R8.17

At most one explicit alignment specifier should appear in an object declaration

Exact

MC3R2.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC3R2.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC3R2.R9.3

Arrays shall not be partially initialized

Exact

MC3R2.R9.4

An element of an object shall not be initialized more than once

Complete

MC3R2.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC3R2.R9.6

An initializer using chained designators shall not contain initializers without designators

Exact

MC3R2.R9.7

Atomic objects shall be appropriately initialized before being accessed

Safe

MC3R2.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC3R2.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC3R2.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC3R2.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC3R2.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC3R2.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC3R2.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC3R2.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC3R2.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC3R2.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC3R2.R11.3

A conversion shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC3R2.R11.4

A conversion should not be performed between a pointer to object and an integer type

Exact

MC3R2.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC3R2.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC3R2.R11.7

A cast shall not be performed between pointer to object and a non-integer arithmetic type

Exact

MC3R2.R11.8

A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer

Exact

MC3R2.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC3R2.R11.10

The _Atomic qualifier shall not be applied to the incomplete type void

Exact

MC3R2.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC3R2.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC3R2.R12.3

The comma operator should not be used

Exact

MC3R2.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC3R2.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC3R2.R12.6

Structure and union members of atomic objects shall not be directly accessed

Exact

MC3R2.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC3R2.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving

Safe

MC3R2.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC3R2.R13.4

The result of an assignment operator should not be used

Exact

MC3R2.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC3R2.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC3R2.R14.1

A loop counter shall not have essentially floating type

Safe

MC3R2.R14.2

A for loop shall be well-formed

Safe

MC3R2.R14.3

Controlling expressions shall not be invariant

Best-effort

MC3R2.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC3R2.R15.1

The goto statement should not be used

Exact

MC3R2.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC3R2.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC3R2.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC3R2.R15.5

A function should have a single point of exit at the end

Exact

MC3R2.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC3R2.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC3R2.R16.1

All switch statements shall be well-formed

Exact

MC3R2.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC3R2.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC3R2.R16.4

Every switch statement shall have a default label

Exact

MC3R2.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC3R2.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC3R2.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC3R2.R17.1

The features of <stdarg.h> shall not be used

Exact

MC3R2.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC3R2.R17.3

A function shall not be declared implicitly

Exact

MC3R2.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC3R2.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC3R2.R17.6

The declaration of an array parameter shall not contain the static keyword between the [ ]

Exact

MC3R2.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC3R2.R17.8

A function parameter should not be modified

Precise

MC3R2.R17.9

A function declared with a _Noreturn function specifier shall not return to its caller

Precise

MC3R2.R17.10

A function declared with a _Noreturn function specifier shall have * void* return type

Exact

MC3R2.R17.11

A function that never returns should be declared with a _Noreturn function specifier

Best-effort

MC3R2.R17.12

A function identifier should only be used with either a preceding &, or with a parenthesized parameter list

Exact

MC3R2.R17.13

A function type shall not be type qualified

Exact

MC3R2.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC3R2.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC3R2.R18.3

The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object

Safe

MC3R2.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC3R2.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC3R2.R18.6

The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC3R2.R18.7

Flexible array members shall not be declared

Exact

MC3R2.R18.8

Variable-length arrays shall not be used

Exact

MC3R2.R18.9

An object with temporary lifetime shall not undergo array-to-pointer conversion

Exact

MC3R2.R18.10

Pointers to variably-modified array types shall not be used

Exact

MC3R2.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC3R2.R19.2

The union keyword should not be used

Exact

MC3R2.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC3R2.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC3R2.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC3R2.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC3R2.R20.5

#undef should not be used

Exact

MC3R2.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC3R2.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC3R2.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC3R2.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC3R2.R20.10

The # and ## preprocessor operators should not be used

Exact

MC3R2.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC3R2.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC3R2.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC3R2.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC3R2.R21.1

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC3R2.R21.2

A reserved identifier or reserved macro name shall not be declared

Exact

MC3R2.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC3R2.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC3R2.R21.5

The standard header file <signal.h> shall not be used

Exact

MC3R2.R21.6

The Standard Library input/output functions shall not be used

Exact

MC3R2.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC3R2.R21.8

The Standard Library termination functions of <stdlib.h> shall not be used

Exact

MC3R2.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC3R2.R21.10

The Standard Library time and date functions shall not be used

Exact

MC3R2.R21.11

The standard header file <tgmath.h> should not be used

Exact

MC3R2.R21.12

The standard header file <fenv.h> shall not be used

Exact

MC3R2.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC3R2.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC3R2.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC3R2.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC3R2.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC3R2.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC3R2.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC3R2.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC3R2.R21.21

The Standard Library function system of <stdlib.h> shall not be used

Exact

MC3R2.R21.22

All operand arguments to any type-generic macros declared in <tgmath.h> shall have an appropriate essential type

Exact

MC3R2.R21.23

All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type

Exact

MC3R2.R21.24

The random number generator functions of <stdlib.h> shall not be used

Exact

MC3R2.R21.25

All memory synchronization operations shall be executed in sequentially consistent order

Safe

MC3R2.R21.26

The Standard Library function mtx_timedlock() shall only be invoked on mutex objects of appropriate mutex type

Complete

MC3R2.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC3R2.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC3R2.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC3R2.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC3R2.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC3R2.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC3R2.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC3R2.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC3R2.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC3R2.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

MC3R2.R22.11

A thread that was previously either joined or detached shall not be subsequently joined nor detached

Safe

MC3R2.R22.12

Thread objects, thread synchronization objects, and thread-specific storage pointers shall only be accessed by the appropriate Standard Library functions

Safe

MC3R2.R22.13

Thread objects, thread synchronization objects and thread-specific storage pointers shall have appropriate storage duration

Exact

MC3R2.R22.14

Thread synchronization objects shall be initialized before being accessed

Safe

MC3R2.R22.15

Thread synchronization objects and thread-specific storage pointers shall not be destroyed until after all threads accessing them have terminated

Safe

MC3R2.R22.16

All mutex objects locked by a thread shall be explicitly unlocked by the same thread

Safe

MC3R2.R22.17

No thread shall unlock a mutex or call cnd_wait() or cnd_timedwait() for a mutex it has not locked before

Safe

MC3R2.R22.18

Non-recursive mutexes shall not be recursively locked

Safe

MC3R2.R22.19

A condition variable shall be associated with at most one mutex object

Safe

MC3R2.R22.20

Thread-specific storage pointers shall be created before being accessed

Safe

MC3R2.R23.1

A generic selection should only be expanded from a macro

Exact

MC3R2.R23.2

A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression

Exact

MC3R2.R23.3

A generic selection should contain at least one non-default association

Exact

MC3R2.R23.4

A generic association shall list an appropriate type

Exact

MC3R2.R23.5

A generic selection should not depend on implicit pointer type conversion

Exact

MC3R2.R23.6

The controlling expression of a generic selection shall have an essential type that matches its standard type

Exact

MC3R2.R23.7

A generic selection that is expanded from a macro should evaluate its argument only once

Exact

MC3R2.R23.8

A default association shall appear as either the first or the last association of a generic selection

Exact

Coverage of Undefined Behaviours for MISRA C:2023

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [58]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC3R2.R1.3

Exact

2

MC3R2.R1.3

Exact

3

MC3R2.R20.10

Unsupported

3

3

3

MC3R2.R1.3

Exact

4

4

4

MC3R2.R1.3

Exact

5

5

MC3R2.D5.1
MC3R2.R9.7

Safe

5

6

6

MC3R2.R1.3

Exact

6

7

7

MC3R2.R1.3

Unsupported

5

MC3R2.R5.2

Exact

6

MC3R2.R17.3

Exact

8

7

8

8

MC3R2.R1.3

Exact

8

9

9

MC3R2.D4.12
MC3R2.R18.6
MC3R2.R18.9
MC3R2.R21.3
MC3R2.R22.13
MC3R2.R22.14
MC3R2.R22.15
MC3R2.R22.20

Safe

9

MC3R2.D4.12
MC3R2.R18.6
MC3R2.R21.3

Safe

9

10

10

MC3R2.D4.12
MC3R2.R18.6
MC3R2.R21.3
MC3R2.R22.15

Safe

10

11

11

MC3R2.R22.13

Safe

11

12

12

MC3R2.R1.3

Unsupported

12

13

13

MC3R2.R11.2
MC3R2.R11.3
MC3R2.R11.4
MC3R2.R11.5

Safe

13

14

14

MC3R2.R1.3

Unsupported

10

14

15

15

MC3R2.R5.6
MC3R2.R5.7
MC3R2.R8.3

Safe

15

MC3R2.D4.1
MC3R2.D4.14
MC3R2.R10.3

Process

16

16

MC3R2.R18.8

Safe

15

17

17

MC3R2.D4.1
MC3R2.D4.14
MC3R2.R10.3

Process

16

18

18

MC3R2.D4.1
MC3R2.D4.14
MC3R2.R10.3

Process

17

19

19

MC3R2.R9.1
MC3R2.R11.2
MC3R2.R11.3
MC3R2.R11.4
MC3R2.R11.5
MC3R2.R19.1

Process

16

18

20

20

MC3R2.R1.3

Exact

21

21

MC3R2.R1.3

Safe

19

22

22

MC3R2.R1.3

Exact

17

20

23

23

MC3R2.R1.3

Exact

21

24

24

MC3R2.R11.1
MC3R2.R11.2
MC3R2.R11.4
MC3R2.R11.6

Safe

22

25

25

MC3R2.R11.2
MC3R2.R11.3
MC3R2.R11.5

Safe

27

23

26

26

MC3R2.R11.1

Safe

4

24

27

27

MC3R2.R1.3

Exact

25

28

28

MC3R2.R1.3

Exact

26

29

29

MC3R2.R1.3

Exact

27

30

30

MC3R2.R1.3

Exact

7

28

31

31

MC3R2.R5.1
MC3R2.R5.2
MC3R2.R5.3
MC3R2.R5.4
MC3R2.R5.5

Exact

29

32

32

MC3R2.R21.2

Exact

11

MC3R2.R1.3

Exact

12

30

33

33

MC3R2.R7.4
MC3R2.R11.4
MC3R2.R11.8

Safe

13

MC3R2.R1.3

Exact

14

MC3R2.R20.2

Exact

31

34

34

MC3R2.R20.2

Exact

18

32

35

35

MC3R2.R13.2
MC3R2.R13.3
MC3R2.R13.4

Safe

19

33

36

36

MC3R2.D4.1
MC3R2.D4.14

Process

20

MC3R2.R11.3
MC3R2.R11.4
MC3R2.R11.5

Safe

34

37

37

MC3R2.R11.3
MC3R2.R11.4
MC3R2.R11.5

Safe

35

MC3R2.R18.9

Safe

21

MC3R2.R1.3

Exact

22

36

38

38

MC3R2.R8.2
MC3R2.R17.3

Safe

23

MC3R2.R8.2
MC3R2.R17.3

Safe

24

MC3R2.R5.6
MC3R2.R5.7
MC3R2.R8.3
MC3R2.R8.4
MC3R2.R8.5
MC3R2.R11.1
MC3R2.R21.2

Safe

25

MC3R2.R8.4
MC3R2.R8.5
MC3R2.R11.1
MC3R2.R21.2
MC3R2.R17.3

Safe

37

39

39

MC3R2.R8.4
MC3R2.R8.5
MC3R2.R11.1
MC3R2.R21.2
MC3R2.R17.3

Safe

38

40

40

MC3R2.R8.2

Safe

39

41

41

MC3R2.R5.6
MC3R2.R5.7
MC3R2.R8.2
MC3R2.R8.3
MC3R2.R8.4
MC3R2.R8.5
MC3R2.R11.1
MC3R2.R21.2

Safe

42

42

MC3R2.R12.6

Exact

26

40

43

43

MC3R2.D4.1
MC3R2.D4.14

Process

28

MC3R2.R11.1

Exact

29

41

44

44

MC3R2.R11.1
MC3R2.R11.2
MC3R2.R11.6
MC3R2.R11.7

Exact

42

45

45

MC3R2.D4.1

Process

46

MC3R2.R1.3

Process

30

43

46

47

MC3R2.D4.14
MC3R2.R18.1

Best-effort

44

47

48

MC3R2.D4.14
MC3R2.R18.1

Best-effort

31

45

48

49

MC3R2.D4.14
MC3R2.R18.2

Best-effort

46

49

50

MC3R2.R18.1

Best-effort

47

50

51

MC3R2.R1.3

Process

32

48

51

52

MC3R2.D4.14
MC3R2.R10.1
MC3R2.R12.2

Safe

49

52

53

MC3R2.R1.3

Unsupported

33

50

53

54

MC3R2.R18.3

Best-effort

34

51

54

55

MC3R2.R19.1

Best-effort

52

55

56

MC3R2.R1.3

Exact

53

56

57

MC3R2.R1.3

Exact

54

57

58

MC3R2.R1.3

Exact

55

58

59

MC3R2.R1.3

Unsupported

35

56

59

60

MC3R2.R1.3

Exact

36

57

60

61

MC3R2.R1.3

Exact

37

58

61

62

MC3R2.R1.3

Exact

38

MC3R2.R6.1

Exact

59

62

63

MC3R2.R18.7

Safe

60

63

64

MC3R2.R1.3

Exact

39

61

64

65

MC3R2.R11.4
MC3R2.R11.8
MC3R2.R19.2

Safe

40

62

65

66

MC3R2.R11.4
MC3R2.R11.8
MC3R2.R19.2

Safe

41

MC3R2.R9.1

Safe

63

66

67

MC3R2.R17.13

Exact

64

67

68

MC3R2.R1.3

Exact

65

68

69

MC3R2.R8.14

Safe

66

69

70

MC3R2.R8.14

Safe

67

70

71

MC3R2.R8.10

Safe

71

72

MC3R2.R17.9

Safe

72

73

MC3R2.R1.3

Exact

73

74

MC3R2.R8.15

Exact

68

74

75

MC3R2.R1.3

Exact

69

75

76

MC3R2.R18.10

Safe

70

76

77

MC3R2.R18.10

Safe

71

77

78

MC3R2.R17.6

Safe

72

78

79

MC3R2.R1.3

Exact

73

79

80

MC3R2.R8.2
MC3R2.R11.1

Safe

74

80

81

MC3R2.R1.3

Unsupported

75

81

82

MC3R2.R1.3

Exact

42

MC3R2.R9.2

Safe

76

82

83

MC3R2.R9.2

Safe

77

83

84

MC3R2.R9.2

Safe

44

78

84

85

MC3R2.R8.6

Exact

79

85

86

MC3R2.R8.2

Safe

80

86

87

MC3R2.R1.3

Exact

45

81

87

88

MC3R2.R17.1

Safe

43

82

88

89

MC3R2.R17.4

Exact

46

83

89

90

MC3R2.R1.3

Exact

91

MC3R2.R1.3

Exact

47

84

90

92

MC3R2.R1.3

Exact

48

85

91

93

MC3R2.R20.3

Exact

86

92

94

MC3R2.R1.3

Unsupported

49

MC3R2.R1.3

Exact

50

87

93

95

MC3R2.R20.6

Exact

51

88

94

96

MC3R2.R20.10

Safe

52

89

95

97

MC3R2.R20.10

Safe

53

90

96

98

MC3R2.R1.3

Exact

91

97

99

MC3R2.R1.3

Exact

92

98

100

MC3R2.R1.3

Exact

54

93

99

101

MC3R2.R21.1

Safe

55

94

100

102

MC3R2.R1.3

Safe

95

101

103

MC3R2.R1.3

Unsupported

56

MC3R2.R17.3
MC3R2.R20.1
MC3R2.R20.4
MC3R2.R21.2

Safe

96

102

104

MC3R2.R20.1

Safe

97

103

105

MC3R2.R20.1
MC3R2.R21.2

Safe

98

104

106

MC3R2.R20.4

Safe

57

MC3R2.R21.1
MC3R2.R21.2

Exact

99

105

107

MC3R2.R21.2

Safe

100

106

108

MC3R2.R21.1
MC3R2.R21.2

Safe

101

107

109

MC3R2.R21.1

Safe

60

102

108

110

MC3R2.D4.11

Best-effort

103

109

111

MC3R2.D4.11
MC3R2.R21.17
MC3R2.R21.18

Best-effort

61

MC3R2.R17.3
MC3R2.R21.2

Safe

62

104

110

112

MC3R2.R1.3

Safe

105

111

113

MC3R2.R1.3

Unsupported

106

112

114

MC3R2.R1.3

Exact

63

107

113

115

MC3R2.D4.11
MC3R2.R21.13

Safe

58

MC3R2.R21.1

Safe

108

114

116

MC3R2.R1.3

Safe

109

115

117

MC3R2.R1.3

Safe

110

116

118

MC3R2.R21.12

Safe

111

117

119

MC3R2.R21.12

Safe

112

118

120

MC3R2.D4.11
MC3R2.R21.12

Safe

90

MC3R2.R21.7

Safe

94

MC3R2.R1.3

Unsupported

113

119

121

MC3R2.R1.3

Unsupported

114

120

122

MC3R2.R21.19

Safe

115

121

123

MC3R2.R21.19

Safe

116

122

124

MC3R2.R21.1
MC3R2.R21.2

Safe

117

123

125

MC3R2.R1.3

Unsupported

64

MC3R2.R21.1
MC3R2.R21.2
MC3R2.R21.4

Safe

118

124

126

MC3R2.R21.1
MC3R2.R21.2
MC3R2.R21.4

Safe

65

119

125

127

MC3R2.R21.4

Safe

120

126

128

MC3R2.R21.4

Safe

66

121

127

129

MC3R2.R21.4

Safe

67

MC3R2.R21.4
MC3R2.R21.5

Safe

122

128

130

MC3R2.R21.5

Safe

123

129

131

MC3R2.R21.5

Safe

130

132

MC3R2.R21.5

Safe

124

131

133

MC3R2.R21.5

Safe

68

MC3R2.R21.5

Safe

125

132

134

MC3R2.R21.5

Safe

69

126

133

135

MC3R2.R21.5

Safe

127

134

136

MC3R2.R21.5

Safe

135

137

MC3R2.R1.3

Safe

128

136

138

MC3R2.R1.3

Safe

70

129

137

139

MC3R2.R17.1

Safe

71

MC3R2.R17.1
MC3R2.R21.1
MC3R2.R21.2

Safe

130

138

140

MC3R2.R17.1
MC3R2.R21.1
MC3R2.R21.2

Safe

75

MC3R2.R17.1

Safe

76

MC3R2.R17.1

Safe

131

139

141

MC3R2.R17.1

Safe

132

140

142

MC3R2.R17.1

Safe

73

MC3R2.R17.1

Safe

74

MC3R2.R17.1

Safe

133

141

143

MC3R2.R17.1

Safe

134

142

144

MC3R2.R17.1

Safe

72

135

143

145

MC3R2.R17.1

Safe

146

MC3R2.R1.3

Safe

59

136

144

147

MC3R2.R1.3

Unsupported

137

145

148

MC3R2.R7.5

Exact

138

146

149

MC3R2.R21.6

Safe

139

147

150

MC3R2.R21.6

Safe

140

148

151

MC3R2.R21.6

Safe

77

141

149

152

MC3R2.R21.6

Safe

142

150

153

MC3R2.R21.6

Safe

78

143

151

154

MC3R2.R21.6

Safe

144

152

155

MC3R2.R21.6

Safe

79

MC3R2.R21.6

Safe

85

MC3R2.R21.6

Safe

145

153

156

MC3R2.R21.6

Safe

146

154

157

MC3R2.R21.6
MC3R2.R21.10

Safe

147

155

158

MC3R2.R21.6

Safe

148

156

159

MC3R2.R21.6

Safe

83

MC3R2.R21.6

Safe

84

MC3R2.R21.6

Safe

149

157

160

MC3R2.R21.6

Safe

82

MC3R2.R21.6

Safe

87

MC3R2.R21.6

Safe

150

158

161

MC3R2.R21.6

Safe

151

159

162

MC3R2.R21.6

Safe

152

160

163

MC3R2.R21.6

Safe

81

153

161

164

MC3R2.R21.6

Safe

97

MC3R2.R21.10

Safe

80

154

162

165

MC3R2.R21.6
MC3R2.R21.10

Safe

86

155

163

166

MC3R2.R21.6

Safe

164

167

MC3R2.R21.6

Safe

89

156

165

168

MC3R2.R21.6

Safe

157

166

169

MC3R2.R21.6

Safe

158

167

170

MC3R2.R21.6

Safe

88

159

168

171

MC3R2.R21.6

Safe

160

169

172

MC3R2.R21.6

Safe

161

170

173

MC3R2.R21.6

Safe

162

171

174

MC3R2.R21.6

Safe

163

172

175

MC3R2.R21.6

Safe

164

173

176

MC3R2.R21.6

Safe

165

174

177

MC3R2.R21.6

Safe

166

175

178

MC3R2.R21.6

Safe

167

176

179

MC3R2.R21.3

Safe

91

168

177

180

MC3R2.R21.3

Safe

178

MC3R2.R21.3

Safe

92

169

179

181

MC3R2.R21.3
MC3R2.R22.2

Safe

170

180

182

MC3R2.R21.3

Safe

171

181

183

MC3R2.R21.3

Safe

93

172

182

184

MC3R2.R21.8

Safe

173

183

185

MC3R2.R21.4

Safe

174

184

186

MC3R2.R21.19

Safe

185

187

MC3R2.R21.5
MC3R2.R21.8

Safe

175

186

188

MC3R2.R21.21

Safe

176

187

189

MC3R2.R21.9

Safe

177

188

190

MC3R2.R21.9

Safe

178

189

191

MC3R2.R21.9

Safe

95

179

190

192

MC3R2.R1.3

Unsupported

96

180

191

193

MC3R2.D4.11
MC3R2.R21.17
MC3R2.R21.18

Best-effort

181

192

194

MC3R2.D4.11
MC3R2.R21.18

Best-effort

182

193

195

MC3R2.R1.3

Unsupported

183

194

196

MC3R2.D4.11

Unsupported

184

195

197

MC3R2.R21.11
MC3R2.R21.22

Safe

185

196

198

MC3R2.R21.11

Safe

199

MC3R2.R1.3

Unsupported

200

MC3R2.R1.3

Unsupported

201

MC3R2.R1.3

Unsupported

202

MC3R2.R1.3

Unsupported

203

MC3R2.R1.3

Unsupported

204

MC3R2.R1.3

Unsupported

197

205

MC3R2.R21.10

Safe

186

198

206

MC3R2.R21.6

Safe

187

199

207

MC3R2.D4.11

Unsupported

188

200

208

MC3R2.R1.3

Unsupported

189

201

209

MC3R2.D4.11

Best-effort

190

202

210

MC3R2.R1.3

Unsupported

191

203

211

MC3R2.R1.3

Unsupported

MISRA C:2023 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2023 coding standard [58].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2023 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC3R2.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC3R2.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC3R2.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC3R2.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC3R2.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC3R2.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC3R2.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC3R2.D4.6

Dir 4.7
Required

no violation report for MC3R2.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC3R2.D4.8

Dir 4.9
Advisory

no violation report for MC3R2.D4.9

Dir 4.10
Required

no violation report for MC3R2.D4.10

Dir 4.11
Required

no violation report for MC3R2.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC3R2.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC3R2.D4.13

Dir 4.14
Required

no violation report for MC3R2.D4.14

after: ensure that the external program input is adequately sanitized before use

Dir 4.15
Required

no violation report or caution report for MC3R2.D4.15

Dir 5.1
Required

no violation report for MC3R2.D5.1

Dir 5.2
Required

no violation report for MC3R2.D5.2

before: Manually verify that no deadlocks are possible, given all the possible resource allocation patterns present in the program;
after: Perform dynamic testing on the program to gain confidence on the absence of deadlocks

Dir 5.3
Required

no violation report for MC3R2.D5.3

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R1.1

Rule 1.2
Advisory
Undecidable
Single T.U.

no violation report or caution report for MC3R2.R1.2

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC3R2.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table is reported with the indicated precision.;
after: nothing to do

Rule 1.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R1.4

Rule 1.5
Required
Undecidable
System

no violation report or caution report for MC3R2.R1.5

Rule 2.1
Required
Undecidable
System

no violation report for MC3R2.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC3R2.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC3R2.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC3R2.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC3R2.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R2.7

Rule 2.8
Advisory
Decidable
System

no violation report for MC3R2.R2.8

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC3R2.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC3R2.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC3R2.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC3R2.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC3R2.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC3R2.R5.9

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R6.2

Rule 6.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R6.3

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3R2.R7.4

Rule 7.5
Mandatory
Decidable
Single T.U.

no violation report for MC3R2.R7.5

Rule 7.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R7.6

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC3R2.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC3R2.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC3R2.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC3R2.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC3R2.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC3R2.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC3R2.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC3R2.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC3R2.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC3R2.R8.14

Rule 8.15
Required
Decidable
System

no violation report for MC3R2.R8.15

Rule 8.16
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R8.16

Rule 8.17
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R8.17

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC3R2.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC3R2.R9.5

Rule 9.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R9.6

Rule 9.7
Mandatory
Undecidable
System

no violation report for MC3R2.R9.7

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC3R2.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.3

Rule 11.4
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.6

Rule 11.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.7

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.9

Rule 11.10
Required
Decidable
Single T.U.

no violation report for MC3R2.R11.10

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC3R2.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC3R2.R12.5

Rule 12.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R12.6

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC3R2.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC3R2.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC3R2.R13.5

Rule 13.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC3R2.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC3R2.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC3R2.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R15.4

Rule 15.5
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC3R2.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC3R2.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC3R2.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC3R2.R17.4

Rule 17.5
Required
Undecidable
System

no violation report or caution report for MC3R2.R17.5

Rule 17.6
Mandatory
Decidable
Single T.U.

no violation report for MC3R2.R17.6

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC3R2.R17.8

Rule 17.9
Mandatory
Undecidable
System

no violation report for MC3R2.R17.9

Rule 17.10
Required
Decidable
Single T.U.

no violation report for MC3R2.R17.10

Rule 17.11
Advisory
Undecidable
System

no violation report for MC3R2.R17.11

after: obtain 100% return point coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 17.12
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R17.12

Rule 17.13
Required
Decidable
Single T.U.

no violation report for MC3R2.R17.13

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC3R2.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC3R2.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC3R2.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC3R2.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC3R2.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC3R2.R18.8

Rule 18.9
Required
Decidable
Single T.U.

no violation report for MC3R2.R18.9

Rule 18.10
Mandatory
Decidable
Single T.U.

no violation report for MC3R2.R18.10

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC3R2.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC3R2.R20.14

Rule 21.1
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.1

Rule 21.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.2

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.10

Rule 21.11
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R21.11

Rule 21.12
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC3R2.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R21.20

Rule 21.21
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.21

Rule 21.22
Mandatory
Decidable
Single T.U.

no violation report for MC3R2.R21.22

Rule 21.23
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.23

Rule 21.24
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.24

Rule 21.25
Required
Decidable
Single T.U.

no violation report for MC3R2.R21.25

Rule 21.26
Required
Undecidable
System

no violation report for MC3R2.R21.26

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC3R2.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC3R2.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC3R2.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC3R2.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC3R2.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC3R2.R22.10

Rule 22.11
Required
Undecidable
System

no violation report for MC3R2.R22.11

Rule 22.12
Mandatory
Undecidable
System

no violation report for MC3R2.R22.12

Rule 22.13
Required
Decidable
Single T.U.

no violation report for MC3R2.R22.13

Rule 22.14
Mandatory
Undecidable
System

no violation report for MC3R2.R22.14

Rule 22.15
Required
Undecidable
System

no violation report for MC3R2.R22.15

Rule 22.16
Required
Undecidable
System

no violation report for MC3R2.R22.16

Rule 22.17
Required
Undecidable
System

no violation report for MC3R2.R22.17

Rule 22.18
Required
Undecidable
System

no violation report for MC3R2.R22.18

Rule 22.19
Required
Undecidable
System

no violation report for MC3R2.R22.19

Rule 22.20
Mandatory
Undecidable
System

no violation report for MC3R2.R22.20

Rule 23.1
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R23.1

Rule 23.2
Required
Decidable
Single T.U.

no violation report for MC3R2.R23.2

Rule 23.3
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R23.3

Rule 23.4
Required
Decidable
Single T.U.

no violation report for MC3R2.R23.4

Rule 23.5
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R23.5

Rule 23.6
Required
Decidable
Single T.U.

no violation report for MC3R2.R23.6

Rule 23.7
Advisory
Decidable
Single T.U.

no violation report for MC3R2.R23.7

Rule 23.8
Required
Decidable
Single T.U.

no violation report for MC3R2.R23.8

MISRA C:2025 Additional Information

This section contains the following additional information related to the support of the MISRA C coding guidelines within this version of ECLAIR:

  • Coverage of the coding guidelines by ECLAIR services;

  • Coverage of undefined behaviours by ECLAIR services;

  • Guideline Enforcement Plans (GEPs) for each guideline.

MISRA C:2025 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2025 coding standard [59].

For all guidelines, the mapping between the MISRA C:2025 guidelines and the ECLAIR service identifiers is one-to-one and straightforward. For example:

  • MISRA C:2025 Directive 1.1 maps to ECLAIR service MC4.D1.1,

  • MISRA C:2025 Rule 1.2 maps to ECLAIR service MC4.R1.2.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC4 synopsis: supported MISRA C:2025 guidelines

Id

Headline

Precision

MC4.D1.1

Any implementation-defined behaviour on which the output of the program depends shall be documented and understood

Process

MC4.D1.2

The use of language extensions should be minimized

Safe

MC4.D2.1

All source files shall compile without any compilation errors

Process

MC4.D3.1

All code shall be traceable to documented requirements

Process

MC4.D4.1

Run-time failures shall be minimized

Process

MC4.D4.2

All usage of assembly language should be documented

Process

MC4.D4.3

Assembly language shall be encapsulated and isolated

Exact

MC4.D4.4

Sections of code should not be “commented out”

Heuristic

MC4.D4.5

Identifiers in the same name space with overlapping visibility should be typographically unambiguous

Exact

MC4.D4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC4.D4.7

If a function returns error information, then that error information shall be tested

Process

MC4.D4.8

If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden

Exact

MC4.D4.9

A function should be used in preference to a function-like macro where they are interchangeable

Complete

MC4.D4.10

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MC4.D4.11

The validity of values passed to library functions shall be checked

Best-effort

MC4.D4.12

Dynamic memory allocation shall not be used

Process

MC4.D4.13

Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Safe

MC4.D4.14

The validity of values received from external sources shall be checked

Best-effort

MC4.D4.15

Evaluation of floating-point expressions shall not lead to the undetected generation of infinities and NaNs

Complete

MC4.D5.1

There shall be no data races between threads

Safe

MC4.D5.2

There shall be no deadlocks between threads

Process

MC4.D5.3

There shall be no dynamic thread creation

Safe

MC4.R1.1

The program shall contain no violations of the standard C syntax and * constraints*, and shall not exceed the implementation’s translation limits

Exact

MC4.R1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MC4.R1.4

Emergent language features shall not be used

Exact

MC4.R1.5

Obsolescent language features shall not be used

Complete

MC4.R2.1

A project shall not contain unreachable code

Best-effort

MC4.R2.2

A project shall not contain dead code

Best-effort

MC4.R2.3

A project should not contain unused type declarations

Exact

MC4.R2.4

A project should not contain unused tag declarations

Exact

MC4.R2.5

A project should not contain unused macro definitions

Exact

MC4.R2.6

A function should not contain unused label declarations

Exact

MC4.R2.7

A function should not contain unused parameters

Exact

MC4.R2.8

A project should not contain unused object definitions

Exact

MC4.R3.1

The character sequences /* and // shall not be used within a comment

Exact

MC4.R3.2

Line-splicing shall not be used in // comments

Exact

MC4.R4.1

Octal and hexadecimal escape sequences shall be terminated

Exact

MC4.R4.2

Trigraphs should not be used

Exact

MC4.R5.1

External identifiers shall be distinct

Exact

MC4.R5.2

Identifiers declared in the same scope and name space shall be distinct

Exact

MC4.R5.3

An identifier declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MC4.R5.4

Macro identifiers shall be distinct

Exact

MC4.R5.5

Identifiers shall be distinct from macro names

Exact

MC4.R5.6

A typedef name shall be a unique identifier

Exact

MC4.R5.7

A tag name shall be a unique identifier

Exact

MC4.R5.8

Identifiers that define objects or functions with external linkage shall be unique

Exact

MC4.R5.9

Identifiers that define objects or functions with internal linkage should be unique

Exact

MC4.R5.10

A reserved identifier or reserved macro name shall not be declared

Exact

MC4.R6.1

Bit-fields shall only be declared with an appropriate type

Exact

MC4.R6.2

Single-bit named bit fields shall not be of a signed type

Exact

MC4.R6.3

A bit field shall not be declared as a member of a union

Exact

MC4.R7.1

Octal constants shall not be used

Exact

MC4.R7.2

A u or U suffix shall be applied to all integer constants that are represented in an unsigned type

Exact

MC4.R7.3

The lowercase character l shall not be used in a literal suffix

Exact

MC4.R7.4

A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char

Complete

MC4.R7.5

The argument of an integer constant macro shall have an appropriate form

Exact

MC4.R7.6

The small integer variants of the minimum-width integer constant macros shall not be used

Exact

MC4.R8.1

Types shall be explicitly specified

Exact

MC4.R8.2

Function types shall be in prototype form with named parameters

Exact

MC4.R8.3

All declarations of an object or function shall use the same names and type qualifiers

Exact

MC4.R8.4

A compatible declaration shall be visible when an object or function with external linkage is defined

Exact

MC4.R8.5

An external object or function shall be declared once in one and only one file

Exact

MC4.R8.6

An identifier with external linkage shall have exactly one external definition

Exact

MC4.R8.7

Functions and objects should not be defined with external linkage if they are referenced in only one translation unit

Exact

MC4.R8.8

The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Exact

MC4.R8.9

An object should be declared at block scope if its identifier only appears in a single function

Exact

MC4.R8.10

An inline function shall be declared with the static storage class

Exact

MC4.R8.11

When an array with external linkage is declared, its size should be explicitly specified

Exact

MC4.R8.12

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MC4.R8.13

A pointer should point to a const-qualified type whenever possible

Best-effort

MC4.R8.14

The restrict type qualifier shall not be used

Exact

MC4.R8.15

All declarations of an object with an explicit alignment specification shall specify the same alignment

Exact

MC4.R8.16

The alignment specification of zero should not appear in an object declaration

Exact

MC4.R8.17

At most one explicit alignment specifier should appear in an object declaration

Exact

MC4.R8.18

There shall be no tentative definitions in a header file

Exact

MC4.R8.19

There shall be no external declarations in a source file

Exact

MC4.R9.1

The value of an object with automatic storage duration shall not be read before it has been set

Safe

MC4.R9.2

The initializer for an aggregate or union shall be enclosed in braces

Exact

MC4.R9.3

Arrays shall not be partially initialized

Exact

MC4.R9.4

An element of an object shall not be initialized more than once

Complete

MC4.R9.5

Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Exact

MC4.R9.6

An initializer using chained designators shall not contain initializers without designators

Exact

MC4.R9.7

Atomic objects shall be appropriately initialized before being accessed

Safe

MC4.R10.1

Operands shall not be of an inappropriate essential type

Exact

MC4.R10.2

Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Exact

MC4.R10.3

The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category

Exact

MC4.R10.4

Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Exact

MC4.R10.5

The value of an expression should not be cast to an inappropriate essential type

Exact

MC4.R10.6

The value of a composite expression shall not be assigned to an object with wider essential type

Exact

MC4.R10.7

If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type

Exact

MC4.R10.8

The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Exact

MC4.R11.1

Conversions shall not be performed between a pointer to a function and any other type

Exact

MC4.R11.2

Conversions shall not be performed between a pointer to an incomplete type and any other type

Exact

MC4.R11.3

A conversion shall not be performed between a pointer to object type and a pointer to a different object type

Exact

MC4.R11.4

A conversion shall not be performed between a pointer to object and an arithmetic type

Exact

MC4.R11.5

A conversion should not be performed from pointer to void into pointer to object

Exact

MC4.R11.6

A cast shall not be performed between pointer to void and an arithmetic type

Exact

MC4.R11.8

A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer

Exact

MC4.R11.9

The macro NULL shall be the only permitted form of integer null pointer constant

Exact

MC4.R11.10

The _Atomic qualifier shall not be applied to the incomplete type void

Exact

MC4.R11.11

Pointers shall not be implicitly compared to NULL

Exact

MC4.R12.1

The precedence of operators within expressions should be made explicit

Exact

MC4.R12.2

The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand

Safe

MC4.R12.3

The comma operator should not be used

Exact

MC4.R12.4

Evaluation of constant expressions should not lead to unsigned integer wrap-around

Exact

MC4.R12.5

The sizeof operator shall not have an operand which is a function parameter declared as “array of type”

Exact

MC4.R12.6

Structure and union members of atomic objects shall not be directly accessed

Exact

MC4.R13.1

Initializer lists shall not contain persistent side effects

Safe

MC4.R13.2

The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving

Safe

MC4.R13.3

A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Exact

MC4.R13.4

The result of an assignment operator should not be used

Exact

MC4.R13.5

The right hand operand of a logical && or || operator shall not contain persistent side effects

Safe

MC4.R13.6

The operand of the sizeof operator shall not contain any expression which has potential side effects

Exact

MC4.R14.1

A loop counter shall not have essentially floating type

Safe

MC4.R14.2

A for loop shall be well-formed

Safe

MC4.R14.3

Controlling expressions shall not be invariant

Best-effort

MC4.R14.4

The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type

Exact

MC4.R15.1

The goto statement should not be used

Exact

MC4.R15.2

The goto statement shall jump to a label declared later in the same function

Exact

MC4.R15.3

Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Exact

MC4.R15.4

There should be no more than one break or goto statement used to terminate any iteration statement

Exact

MC4.R15.5

A function should have a single point of exit at the end

Exact

MC4.R15.6

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MC4.R15.7

All if ... else if constructs shall be terminated with an else statement

Exact

MC4.R16.1

All switch statements shall be well-formed

Exact

MC4.R16.2

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC4.R16.3

An unconditional break statement shall terminate every * switch-clause*

Exact

MC4.R16.4

Every switch statement shall have a default label

Exact

MC4.R16.5

A default label shall appear as either the first or the last switch label of a switch statement

Exact

MC4.R16.6

Every switch statement shall have at least two switch-clauses

Exact

MC4.R16.7

A switch-expression shall not have essentially Boolean type

Exact

MC4.R17.1

The features of <stdarg.h> shall not be used

Exact

MC4.R17.2

Functions shall not call themselves, either directly or indirectly

Safe

MC4.R17.3

A function shall not be declared implicitly

Exact

MC4.R17.4

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC4.R17.5

The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements

Safe

MC4.R17.7

The value returned by a function having non-void return type shall be * used*

Exact

MC4.R17.8

A function parameter should not be modified

Precise

MC4.R17.9

A function declared with a _Noreturn function specifier shall not return to its caller

Precise

MC4.R17.10

A function declared with a _Noreturn function specifier shall have * void* return type

Exact

MC4.R17.11

A function that never returns should be declared with a _Noreturn function specifier

Best-effort

MC4.R17.12

A function identifier should only be used with either a preceding &, or with a parenthesized parameter list

Exact

MC4.R17.13

A function type shall not be type qualified

Exact

MC4.R18.1

A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand

Best-effort

MC4.R18.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Safe

MC4.R18.3

The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object

Safe

MC4.R18.4

The +, -, += and -= operators should not be applied to an expression of pointer type

Complete

MC4.R18.5

Declarations should contain no more than two levels of pointer nesting

Exact

MC4.R18.6

The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist

Safe

MC4.R18.7

Flexible array members shall not be declared

Exact

MC4.R18.8

Variable-length arrays shall not be used

Exact

MC4.R18.9

An object with temporary lifetime shall not undergo array-to-pointer conversion

Exact

MC4.R18.10

Pointers to variably-modified array types shall not be used

Exact

MC4.R19.1

An object shall not be assigned or copied to an overlapping object

Best-effort

MC4.R19.2

The union keyword should not be used

Exact

MC4.R19.3

A union member shall not be read unless it has been previously set

Safe

MC4.R20.1

#include directives should only be preceded by preprocessor directives or comments

Exact

MC4.R20.2

The ', " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MC4.R20.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC4.R20.4

A macro shall not be defined with the same name as a keyword

Exact

MC4.R20.5

#undef should not be used

Exact

MC4.R20.6

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MC4.R20.7

Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

Exact

MC4.R20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Exact

MC4.R20.9

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define‘d before evaluation

Exact

MC4.R20.10

The # and ## preprocessor operators should not be used

Exact

MC4.R20.11

A macro parameter immediately following a # operator shall not immediately be followed by a ## operator

Exact

MC4.R20.12

A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Exact

MC4.R20.13

A line whose first token is # shall be a valid preprocessing directive

Exact

MC4.R20.14

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MC4.R20.15

#define and #undef shall not be used on a reserved identifier or reserved macro name

Exact

MC4.R21.3

The memory allocation and deallocation functions of <stdlib.h> shall not be used

Exact

MC4.R21.4

The standard header file <setjmp.h> shall not be used

Exact

MC4.R21.5

The standard header file <signal.h> shall not be used

Exact

MC4.R21.6

The Standard Library input/output functions shall not be used

Exact

MC4.R21.7

The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used

Exact

MC4.R21.8

The Standard Library termination functions of <stdlib.h> shall not be used

Exact

MC4.R21.9

The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used

Exact

MC4.R21.10

The Standard Library time and date functions shall not be used

Exact

MC4.R21.11

The standard header file <tgmath.h> should not be used

Exact

MC4.R21.12

The standard header file <fenv.h> shall not be used

Exact

MC4.R21.13

Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF

Safe

MC4.R21.14

The Standard Library function memcmp shall not be used to compare null terminated strings

Safe

MC4.R21.15

The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Exact

MC4.R21.16

The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type

Exact

MC4.R21.17

Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters

Best-effort

MC4.R21.18

The size_t argument passed to any function in <string.h> shall have an appropriate value

Safe

MC4.R21.19

The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Complete

MC4.R21.20

The pointer returned by the Standard Library functions asctime, ctime , gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function

Safe

MC4.R21.21

The Standard Library function system of <stdlib.h> shall not be used

Exact

MC4.R21.22

All operand arguments to any type-generic macros declared in <tgmath.h> shall have an appropriate essential type

Exact

MC4.R21.23

All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type

Exact

MC4.R21.24

The random number generator functions of <stdlib.h> shall not be used

Exact

MC4.R21.25

All memory synchronization operations shall be executed in sequentially consistent order

Safe

MC4.R21.26

The Standard Library function mtx_timedlock() shall only be invoked on mutex objects of appropriate mutex type

Complete

MC4.R22.1

All resources obtained dynamically by means of Standard Library functions shall be explicitly released

Best-effort

MC4.R22.2

A block of memory shall only be freed if it was allocated by means of a Standard Library function

Best-effort

MC4.R22.3

The same file shall not be open for read and write access at the same time on different streams

Safe

MC4.R22.4

There shall be no attempt to write to a stream which has been opened as read-only

Safe

MC4.R22.5

A pointer to a FILE object shall not be dereferenced

Safe

MC4.R22.6

The value of a pointer to a FILE shall not be used after the associated stream has been closed

Safe

MC4.R22.7

The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF

Best-effort

MC4.R22.8

The value of errno shall be set to zero prior to a call to an * errno-setting-function*

Safe

MC4.R22.9

The value of errno shall be tested against zero after calling an * errno-setting-function*

Safe

MC4.R22.10

The value of errno shall only be tested when the last function to be called was an errno-setting-function

Safe

MC4.R22.11

A thread that was previously either joined or detached shall not be subsequently joined nor detached

Safe

MC4.R22.12

Thread objects, thread synchronization objects, and thread-specific storage pointers shall only be accessed by the appropriate Standard Library functions

Safe

MC4.R22.13

Thread objects, thread synchronization objects and thread-specific storage pointers shall have appropriate storage duration

Exact

MC4.R22.14

Thread synchronization objects shall be initialized before being accessed

Safe

MC4.R22.15

Thread synchronization objects and thread-specific storage pointers shall not be destroyed until after all threads accessing them have terminated

Safe

MC4.R22.16

All mutex objects locked by a thread shall be explicitly unlocked by the same thread

Safe

MC4.R22.17

No thread shall unlock a mutex or call cnd_wait() or cnd_timedwait() for a mutex it has not locked before

Safe

MC4.R22.18

Non-recursive mutexes shall not be recursively locked

Safe

MC4.R22.19

A condition variable shall be associated with at most one mutex object

Safe

MC4.R22.20

Thread-specific storage pointers shall be created before being accessed

Safe

MC4.R23.1

A generic selection should only be expanded from a macro

Exact

MC4.R23.2

A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression

Exact

MC4.R23.3

A generic selection should contain at least one non-default association

Exact

MC4.R23.4

A generic association shall list an appropriate type

Exact

MC4.R23.5

A generic selection should not depend on implicit pointer type conversion

Exact

MC4.R23.6

The controlling expression of a generic selection shall have an essential type that matches its standard type

Exact

MC4.R23.7

A generic selection that is expanded from a macro should evaluate its argument only once

Exact

MC4.R23.8

A default association shall appear as either the first or the last association of a generic selection

Exact

Coverage of Undefined Behaviours for MISRA C:2025

This table presents a subset of undefined behaviours that, when analyzed by ECLAIR with the given services enabled, are reported, each with the given precision. This table is based on the classification found in Appendix H of [59]. Any undefined behaviour that is not mentioned below may present false negatives and false positives when analyzed by ECLAIR. An undefined behaviour is considered covered also when it results in a violation of Rule 1.1.

The table adopts the following conventions:

  • The C90, C99, C11, C18 columns contain the number of the undefined behaviour in the corresponding version of the C standard.

  • The Rules column contains all the rules that, according to BUGSENG, when complied with, prevent the undefined behaviour from happening. Note that the content of this column is possibly a superset of the ones listed by MISRA in Appendix H.

  • The Precision column contains the degree of precision of the ECLAIR service that implements the rules mentioned in the Rules column in signaling the presence of the corresponding undefined behaviour. The meaning of its contents are the same as the previous table.

Coverage of undefined behaviours by guidelines

C90

C99

C11

C18

Rules

Precision

1

2

2

2

MC4.R1.3

Exact

2

MC4.R1.3

Exact

3

MC4.R20.10

Unsupported

3

3

3

MC4.R1.3

Exact

4

4

4

MC4.R1.3

Exact

5

5

MC4.D5.1
MC4.R9.7

Safe

5

6

6

MC4.R1.3

Exact

6

7

7

MC4.R1.3

Unsupported

5

MC4.R5.2

Exact

6

MC4.R17.3

Exact

8

7

8

8

MC4.R1.3

Exact

8

9

9

MC4.D4.12
MC4.R18.6
MC4.R18.9
MC4.R21.3
MC4.R22.13
MC4.R22.14
MC4.R22.15
MC4.R22.20

Safe

9

MC4.D4.12
MC4.R18.6
MC4.R21.3

Safe

9

10

10

MC4.D4.12
MC4.R18.6
MC4.R21.3
MC4.R22.15

Safe

10

11

11

MC4.R22.13

Safe

11

12

12

MC4.R1.3

Unsupported

12

13

13

MC4.R11.2
MC4.R11.3
MC4.R11.4
MC4.R11.5

Safe

13

14

14

MC4.R1.3

Unsupported

10

14

15

15

MC4.R5.6
MC4.R5.7
MC4.R8.3

Safe

15

MC4.D4.1
MC4.D4.14
MC4.R10.3

Process

16

16

MC4.R18.8

Safe

15

17

17

MC4.D4.1
MC4.D4.14
MC4.R10.3

Process

16

18

18

MC4.D4.1
MC4.D4.14
MC4.R10.3

Process

17

19

19

MC4.R9.1
MC4.R11.2
MC4.R11.3
MC4.R11.4
MC4.R11.5
MC4.R19.1

Process

16

18

20

20

MC4.R1.3

Exact

21

21

MC4.R1.3

Safe

19

22

22

MC4.R1.3

Exact

17

20

23

23

MC4.R1.3

Exact

21

24

24

MC4.R11.1
MC4.R11.2
MC4.R11.4
MC4.R11.6

Safe

22

25

25

MC4.R11.2
MC4.R11.3
MC4.R11.5

Safe

27

23

26

26

MC4.R11.1

Safe

4

24

27

27

MC4.R1.3

Exact

25

28

28

MC4.R1.3

Exact

26

29

29

MC4.R1.3

Exact

27

30

30

MC4.R1.3

Exact

7

28

31

31

MC4.R5.1
MC4.R5.2
MC4.R5.3
MC4.R5.4
MC4.R5.5

Exact

29

32

32

MC4.R5.10

Exact

11

MC4.R1.3

Exact

12

30

33

33

MC4.R7.4
MC4.R11.4
MC4.R11.8

Safe

13

MC4.R1.3

Exact

14

MC4.R20.2

Exact

31

34

34

MC4.R20.2

Exact

18

32

35

35

MC4.R13.2
MC4.R13.3
MC4.R13.4

Safe

19

33

36

36

MC4.D4.1
MC4.D4.14

Process

20

MC4.R11.3
MC4.R11.4
MC4.R11.5

Safe

34

37

37

MC4.R11.3
MC4.R11.4
MC4.R11.5

Safe

35

MC4.R18.9

Safe

21

MC4.R1.3

Exact

22

36

38

38

MC4.R8.2
MC4.R17.3

Safe

23

MC4.R8.2
MC4.R17.3

Safe

24

MC4.R5.6
MC4.R5.7
MC4.R8.3
MC4.R8.4
MC4.R8.5
MC4.R11.1
MC4.R5.10

Safe

25

MC4.R8.4
MC4.R8.5
MC4.R11.1
MC4.R5.10
MC4.R17.3

Safe

37

39

39

MC4.R8.4
MC4.R8.5
MC4.R11.1
MC4.R5.10
MC4.R17.3

Safe

38

40

40

MC4.R8.2

Safe

39

41

41

MC4.R5.6
MC4.R5.7
MC4.R8.2
MC4.R8.3
MC4.R8.4
MC4.R8.5
MC4.R11.1
MC4.R5.10

Safe

42

42

MC4.R12.6

Exact

26

40

43

43

MC4.D4.1
MC4.D4.14

Process

28

MC4.R11.1

Exact

29

41

44

44

MC4.R11.1
MC4.R11.2
MC4.R11.6
MC4.R11.4

Exact

42

45

45

MC4.D4.1

Process

46

MC4.R1.3

Process

30

43

46

47

MC4.D4.14
MC4.R18.1

Best-effort

44

47

48

MC4.D4.14
MC4.R18.1

Best-effort

31

45

48

49

MC4.D4.14
MC4.R18.2

Best-effort

46

49

50

MC4.R18.1

Best-effort

47

50

51

MC4.R1.3

Process

32

48

51

52

MC4.D4.14
MC4.R10.1
MC4.R12.2

Safe

49

52

53

MC4.R1.3

Unsupported

33

50

53

54

MC4.R18.3

Best-effort

34

51

54

55

MC4.R19.1

Best-effort

52

55

56

MC4.R1.3

Exact

53

56

57

MC4.R1.3

Exact

54

57

58

MC4.R1.3

Exact

55

58

59

MC4.R1.3

Unsupported

35

56

59

60

MC4.R1.3

Exact

36

57

60

61

MC4.R1.3

Exact

37

58

61

62

MC4.R1.3

Exact

38

MC4.R6.1

Exact

59

62

63

MC4.R18.7

Safe

60

63

64

MC4.R1.3

Exact

39

61

64

65

MC4.R11.4
MC4.R11.8
MC4.R19.2

Safe

40

62

65

66

MC4.R11.4
MC4.R11.8
MC4.R19.2

Safe

41

MC4.R9.1

Safe

63

66

67

MC4.R17.13

Exact

64

67

68

MC4.R1.3

Exact

65

68

69

MC4.R8.14

Safe

66

69

70

MC4.R8.14

Safe

67

70

71

MC4.R8.10

Safe

71

72

MC4.R17.9

Safe

72

73

MC4.R1.3

Exact

73

74

MC4.R8.15

Exact

68

74

75

MC4.R1.3

Exact

69

75

76

MC4.R18.10

Safe

70

76

77

MC4.R18.10

Safe

71

77

78

MC4.R17.5

Safe

72

78

79

MC4.R1.3

Exact

73

79

80

MC4.R8.2
MC4.R11.1

Safe

74

80

81

MC4.R1.3

Unsupported

75

81

82

MC4.R1.3

Exact

42

MC4.R9.2

Safe

76

82

83

MC4.R9.2

Safe

77

83

84

MC4.R9.2

Safe

44

78

84

85

MC4.R8.6

Exact

79

85

86

MC4.R8.2

Safe

80

86

87

MC4.R1.3

Exact

45

81

87

88

MC4.R17.1

Safe

43

82

88

89

MC4.R17.4

Exact

46

83

89

90

MC4.R1.3

Exact

91

MC4.R1.3

Exact

47

84

90

92

MC4.R1.3

Exact

48

85

91

93

MC4.R20.3

Exact

86

92

94

MC4.R1.3

Unsupported

49

MC4.R1.3

Exact

50

87

93

95

MC4.R20.6

Exact

51

88

94

96

MC4.R20.10

Safe

52

89

95

97

MC4.R20.10

Safe

53

90

96

98

MC4.R1.3

Exact

91

97

99

MC4.R1.3

Exact

92

98

100

MC4.R1.3

Exact

54

93

99

101

MC4.R20.15

Safe

55

94

100

102

MC4.R1.3

Safe

95

101

103

MC4.R1.3

Unsupported

56

MC4.R17.3
MC4.R20.1
MC4.R20.4
MC4.R5.10

Safe

96

102

104

MC4.R20.1

Safe

97

103

105

MC4.R20.1
MC4.R5.10

Safe

98

104

106

MC4.R20.4

Safe

57

MC4.R20.15
MC4.R5.10

Exact

99

105

107

MC4.R5.10

Safe

100

106

108

MC4.R20.15
MC4.R5.10

Safe

101

107

109

MC4.R20.15

Safe

60

102

108

110

MC4.D4.11

Best-effort

103

109

111

MC4.D4.11
MC4.R21.17
MC4.R21.18

Best-effort

61

MC4.R17.3
MC4.R5.10

Safe

62

104

110

112

MC4.R1.3

Safe

105

111

113

MC4.R1.3

Unsupported

106

112

114

MC4.R1.3

Exact

63

107

113

115

MC4.D4.11
MC4.R21.13

Safe

58

MC4.R20.15

Safe

108

114

116

MC4.R1.3

Safe

109

115

117

MC4.R1.3

Safe

110

116

118

MC4.R21.12

Safe

111

117

119

MC4.R21.12

Safe

112

118

120

MC4.D4.11
MC4.R21.12

Safe

90

MC4.R21.7

Safe

94

MC4.R1.3

Unsupported

113

119

121

MC4.R1.3

Unsupported

114

120

122

MC4.R21.19

Safe

115

121

123

MC4.R21.19

Safe

116

122

124

MC4.R20.15
MC4.R5.10

Safe

117

123

125

MC4.R1.3

Unsupported

64

MC4.R20.15
MC4.R5.10
MC4.R21.4

Safe

118

124

126

MC4.R20.15
MC4.R5.10
MC4.R21.4

Safe

65

119

125

127

MC4.R21.4

Safe

120

126

128

MC4.R21.4

Safe

66

121

127

129

MC4.R21.4

Safe

67

MC4.R21.4
MC4.R21.5

Safe

122

128

130

MC4.R21.5

Safe

123

129

131

MC4.R21.5

Safe

130

132

MC4.R21.5

Safe

124

131

133

MC4.R21.5

Safe

68

MC4.R21.5

Safe

125

132

134

MC4.R21.5

Safe

69

126

133

135

MC4.R21.5

Safe

127

134

136

MC4.R21.5

Safe

135

137

MC4.R1.3

Safe

128

136

138

MC4.R1.3

Safe

70

129

137

139

MC4.R17.1

Safe

71

MC4.R17.1
MC4.R20.15
MC4.R5.10

Safe

130

138

140

MC4.R17.1
MC4.R20.15
MC4.R5.10

Safe

75

MC4.R17.1

Safe

76

MC4.R17.1

Safe

131

139

141

MC4.R17.1

Safe

132

140

142

MC4.R17.1

Safe

73

MC4.R17.1

Safe

74

MC4.R17.1

Safe

133

141

143

MC4.R17.1

Safe

134

142

144

MC4.R17.1

Safe

72

135

143

145

MC4.R17.1

Safe

146

MC4.R1.3

Safe

59

136

144

147

MC4.R1.3

Unsupported

137

145

148

MC4.R7.5

Exact

138

146

149

MC4.R21.6

Safe

139

147

150

MC4.R21.6

Safe

140

148

151

MC4.R21.6

Safe

77

141

149

152

MC4.R21.6

Safe

142

150

153

MC4.R21.6

Safe

78

143

151

154

MC4.R21.6

Safe

144

152

155

MC4.R21.6

Safe

79

MC4.R21.6

Safe

85

MC4.R21.6

Safe

145

153

156

MC4.R21.6

Safe

146

154

157

MC4.R21.6
MC4.R21.10

Safe

147

155

158

MC4.R21.6

Safe

148

156

159

MC4.R21.6

Safe

83

MC4.R21.6

Safe

84

MC4.R21.6

Safe

149

157

160

MC4.R21.6

Safe

82

MC4.R21.6

Safe

87

MC4.R21.6

Safe

150

158

161

MC4.R21.6

Safe

151

159

162

MC4.R21.6

Safe

152

160

163

MC4.R21.6

Safe

81

153

161

164

MC4.R21.6

Safe

97

MC4.R21.10

Safe

80

154

162

165

MC4.R21.6
MC4.R21.10

Safe

86

155

163

166

MC4.R21.6

Safe

164

167

MC4.R21.6

Safe

89

156

165

168

MC4.R21.6

Safe

157

166

169

MC4.R21.6

Safe

158

167

170

MC4.R21.6

Safe

88

159

168

171

MC4.R21.6

Safe

160

169

172

MC4.R21.6

Safe

161

170

173

MC4.R21.6

Safe

162

171

174

MC4.R21.6

Safe

163

172

175

MC4.R21.6

Safe

164

173

176

MC4.R21.6

Safe

165

174

177

MC4.R21.6

Safe

166

175

178

MC4.R21.6

Safe

167

176

179

MC4.R21.3

Safe

91

168

177

180

MC4.R21.3

Safe

178

MC4.R21.3

Safe

92

169

179

181

MC4.R21.3
MC4.R22.2

Safe

170

180

182

MC4.R21.3

Safe

171

181

183

MC4.R21.3

Safe

93

172

182

184

MC4.R21.8

Safe

173

183

185

MC4.R21.4

Safe

174

184

186

MC4.R21.19

Safe

185

187

MC4.R21.5
MC4.R21.8

Safe

175

186

188

MC4.R21.21

Safe

176

187

189

MC4.R21.9

Safe

177

188

190

MC4.R21.9

Safe

178

189

191

MC4.R21.9

Safe

95

179

190

192

MC4.R1.3

Unsupported

96

180

191

193

MC4.D4.11
MC4.R21.17
MC4.R21.18

Best-effort

181

192

194

MC4.D4.11
MC4.R21.18

Best-effort

182

193

195

MC4.R1.3

Unsupported

183

194

196

MC4.D4.11

Unsupported

184

195

197

MC4.R21.11
MC4.R21.22

Safe

185

196

198

MC4.R21.11

Safe

199

MC4.R1.3

Unsupported

200

MC4.R1.3

Unsupported

201

MC4.R1.3

Unsupported

202

MC4.R1.3

Unsupported

203

MC4.R1.3

Unsupported

204

MC4.R1.3

Unsupported

197

205

MC4.R21.10

Safe

186

198

206

MC4.R21.6

Safe

187

199

207

MC4.D4.11

Unsupported

188

200

208

MC4.R1.3

Unsupported

189

201

209

MC4.D4.11

Best-effort

190

202

210

MC4.R1.3

Unsupported

191

203

211

MC4.R1.3

Unsupported

MISRA C:2025 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2025 coding standard [59].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2025 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Dir 1.1
Required

no violation report or caution report for MC4.D1.1

before: select and understand those implementation-defined behaviors that may affect the program’s actions and, for each selected behavior, add a configuration specifying and documenting the expected behavior

Dir 1.2
Advisory

no violation report or caution report for MC4.D1.2

Dir 2.1
Required

no violation report for MC.D2.1 or B.PARSER

before: ensure that the build procedure stops whenever an unexpected error is detected;
after: check all messages output by the build procedure for errors

Dir 3.1
Required

no violation report for MC4.D3.1

before: provide a complete and accurate configuration for the documented requirements.

Dir 4.1
Required

no violation report for MC4.D4.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

Dir 4.2
Advisory

no violation report for MC4.D4.2

before: ensure that every use of assembler and its interface with C is documented

Dir 4.3
Required

no violation report for MC4.D4.3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

Dir 4.4
Advisory

no violation report for MC4.D4.4

after: check for any residual unreported commented out code

Dir 4.5
Advisory

no violation report for MC4.D4.5

before: provide a complete and accurate configuration for what is meant by typographically ambiguous in the context of the specific project

Dir 4.6
Advisory

no violation report for MC4.D4.6

Dir 4.7
Required

no violation report for MC4.D4.7

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

Dir 4.8
Advisory

no violation report for MC4.D4.8

Dir 4.9
Advisory

no violation report for MC4.D4.9

Dir 4.10
Required

no violation report for MC4.D4.10

Dir 4.11
Required

no violation report for MC4.D4.11

after: ensure that the source codes’ validity checks cover the functions’ requirements

Dir 4.12
Required

no violation report for MC4.D4.12

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Dir 4.13
Advisory

no violation report or caution report for MC4.D4.13

Dir 4.14
Required

no violation report for MC4.D4.14

after: ensure that the external program input is adequately sanitized before use

Dir 4.15
Required

no violation report or caution report for MC4.D4.15

Dir 5.1
Required

no violation report for MC4.D5.1

Dir 5.2
Required

no violation report for MC4.D5.2

before: Manually verify that no deadlocks are possible, given all the possible resource allocation patterns present in the program;
after: Perform dynamic testing on the program to gain confidence on the absence of deadlocks

Dir 5.3
Required

no violation report for MC4.D5.3

Rule 1.1
Required
Decidable
Single T.U.

no violation report for MC4.R1.1

Rule 1.3
Required
Undecidable
System

no violation report or caution report for MC4.R1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors. Each undefined behaviour listed in this table is reported with the indicated precision.;
after: nothing to do

Rule 1.4
Required
Decidable
Single T.U.

no violation report for MC4.R1.4

Rule 1.5
Required
Undecidable
System

no violation report or caution report for MC4.R1.5

Rule 2.1
Required
Undecidable
System

no violation report for MC4.R2.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 2.2
Required
Undecidable
System

no violation report or caution report for MC4.R2.2

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

Rule 2.3
Advisory
Decidable
System

no violation report for MC4.R2.3

Rule 2.4
Advisory
Decidable
System

no violation report for MC4.R2.4

Rule 2.5
Advisory
Decidable
System

no violation report for MC4.R2.5

Rule 2.6
Advisory
Decidable
Single T.U.

no violation report for MC4.R2.6

Rule 2.7
Advisory
Decidable
Single T.U.

no violation report for MC4.R2.7

Rule 2.8
Advisory
Decidable
System

no violation report for MC4.R2.8

Rule 3.1
Required
Decidable
Single T.U.

no violation report for MC4.R3.1

Rule 3.2
Required
Decidable
Single T.U.

no violation report for MC4.R3.2

Rule 4.1
Required
Decidable
Single T.U.

no violation report for MC4.R4.1

Rule 4.2
Advisory
Decidable
Single T.U.

no violation report for MC4.R4.2

Rule 5.1
Required
Decidable
System

no violation report for MC4.R5.1

Rule 5.2
Required
Decidable
Single T.U.

no violation report for MC4.R5.2

Rule 5.3
Required
Decidable
Single T.U.

no violation report for MC4.R5.3

Rule 5.4
Required
Decidable
Single T.U.

no violation report for MC4.R5.4

Rule 5.5
Required
Decidable
Single T.U.

no violation report for MC4.R5.5

Rule 5.6
Required
Decidable
System

no violation report for MC4.R5.6

Rule 5.7
Required
Decidable
System

no violation report for MC4.R5.7

Rule 5.8
Required
Decidable
System

no violation report for MC4.R5.8

Rule 5.9
Advisory
Decidable
System

no violation report for MC4.R5.9

Rule 5.10
Required
Decidable
Single T.U.

no violation report for MC4.R5.10

Rule 6.1
Required
Decidable
Single T.U.

no violation report for MC4.R6.1

Rule 6.2
Required
Decidable
Single T.U.

no violation report for MC4.R6.2

Rule 6.3
Required
Decidable
Single T.U.

no violation report for MC4.R6.3

Rule 7.1
Required
Decidable
Single T.U.

no violation report for MC4.R7.1

Rule 7.2
Required
Decidable
Single T.U.

no violation report for MC4.R7.2

Rule 7.3
Required
Decidable
Single T.U.

no violation report for MC4.R7.3

Rule 7.4
Required
Decidable
Single T.U.

no violation report or caution report for MC4.R7.4

Rule 7.5
Mandatory
Decidable
Single T.U.

no violation report for MC4.R7.5

Rule 7.6
Required
Decidable
Single T.U.

no violation report for MC4.R7.6

Rule 8.1
Required
Decidable
Single T.U.

no violation report for MC4.R8.1

Rule 8.2
Required
Decidable
Single T.U.

no violation report for MC4.R8.2

Rule 8.3
Required
Decidable
System

no violation report for MC4.R8.3

Rule 8.4
Required
Decidable
Single T.U.

no violation report for MC4.R8.4

Rule 8.5
Required
Decidable
System

no violation report for MC4.R8.5

Rule 8.6
Required
Decidable
System

no violation report for MC4.R8.6

Rule 8.7
Advisory
Decidable
System

no violation report for MC4.R8.7

Rule 8.8
Required
Decidable
Single T.U.

no violation report for MC4.R8.8

Rule 8.9
Advisory
Decidable
System

no violation report for MC4.R8.9

Rule 8.10
Required
Decidable
Single T.U.

no violation report for MC4.R8.10

Rule 8.11
Advisory
Decidable
Single T.U.

no violation report for MC4.R8.11

Rule 8.12
Required
Decidable
Single T.U.

no violation report for MC4.R8.12

Rule 8.13
Advisory
Undecidable
System

no violation report for MC4.R8.13

after: check each non-const pointer with program scope for compliance

Rule 8.14
Required
Decidable
Single T.U.

no violation report for MC4.R8.14

Rule 8.15
Required
Decidable
System

no violation report for MC4.R8.15

Rule 8.16
Advisory
Decidable
Single T.U.

no violation report for MC4.R8.16

Rule 8.17
Advisory
Decidable
Single T.U.

no violation report for MC4.R8.17

Rule 8.18
Required
Decidable
Single T.U.

no violation report for MC4.R8.18

Rule 8.19
Advisory
Decidable
Single T.U.

no violation report for MC4.R8.19

Rule 9.1
Mandatory
Undecidable
System

no

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 9.2
Required
Decidable
Single T.U.

no violation report for MC4.R9.2

Rule 9.3
Required
Decidable
Single T.U.

no violation report for MC4.R9.3

Rule 9.4
Required
Decidable
Single T.U.

no violation report or caution report for MC4.R9.4

Rule 9.5
Required
Decidable
Single T.U.

no violation report for MC4.R9.5

Rule 9.6
Required
Decidable
Single T.U.

no violation report for MC4.R9.6

Rule 9.7
Mandatory
Undecidable
System

no violation report for MC4.R9.7

Rule 10.1
Required
Decidable
Single T.U.

no violation report for MC4.R10.1

Rule 10.2
Required
Decidable
Single T.U.

no violation report for MC4.R10.2

Rule 10.3
Required
Decidable
Single T.U.

no violation report for MC4.R10.3

Rule 10.4
Required
Decidable
Single T.U.

no violation report for MC4.R10.4

Rule 10.5
Advisory
Decidable
Single T.U.

no violation report for MC4.R10.5

Rule 10.6
Required
Decidable
Single T.U.

no violation report for MC4.R10.6

Rule 10.7
Required
Decidable
Single T.U.

no violation report for MC4.R10.7

Rule 10.8
Required
Decidable
Single T.U.

no violation report for MC4.R10.8

Rule 11.1
Required
Decidable
Single T.U.

no violation report for MC4.R11.1

Rule 11.2
Required
Decidable
Single T.U.

no violation report for MC4.R11.2

Rule 11.3
Required
Decidable
Single T.U.

no violation report for MC4.R11.3

Rule 11.4
Required
Decidable
Single T.U.

no violation report for MC4.R11.4

Rule 11.5
Advisory
Decidable
Single T.U.

no violation report for MC4.R11.5

Rule 11.6
Required
Decidable
Single T.U.

no violation report for MC4.R11.6

Rule 11.8
Required
Decidable
Single T.U.

no violation report for MC4.R11.8

Rule 11.9
Required
Decidable
Single T.U.

no violation report for MC4.R11.9

Rule 11.10
Required
Decidable
Single T.U.

no violation report for MC4.R11.10

Rule 11.11
Required
Decidable
Single T.U.

no violation report for MC4.R11.11

Rule 12.1
Advisory
Decidable
Single T.U.

no violation report for MC4.R12.1

Rule 12.2
Required
Undecidable
System

no violation report or caution report for MC4.R12.2

Rule 12.3
Advisory
Decidable
Single T.U.

no violation report for MC4.R12.3

Rule 12.4
Advisory
Decidable
Single T.U.

no violation report for MC4.R12.4

Rule 12.5
Mandatory
Decidable
Single T.U.

no violation report for MC4.R12.5

Rule 12.6
Required
Decidable
Single T.U.

no violation report for MC4.R12.6

Rule 13.1
Required
Undecidable
System

no violation report or caution report for MC4.R13.1

Rule 13.2
Required
Undecidable
System

no violation report or caution report for MC4.R13.2

Rule 13.3
Advisory
Decidable
Single T.U.

no violation report for MC4.R13.3

Rule 13.4
Advisory
Decidable
Single T.U.

no violation report for MC4.R13.4

Rule 13.5
Required
Undecidable
System

no violation report or caution report for MC4.R13.5

Rule 13.6
Required
Decidable
Single T.U.

no violation report for MC4.R13.6

Rule 14.1
Required
Undecidable
System

no violation report or caution report for MC4.R14.1

Rule 14.2
Required
Undecidable
System

no violation report or caution report for MC4.R14.2

Rule 14.3
Required
Undecidable
System

no violation report for MC4.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.3
Required
Undecidable
System

no violation report for MC4.R14.3

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 14.4
Required
Decidable
Single T.U.

no violation report for MC4.R14.4

Rule 15.1
Advisory
Decidable
Single T.U.

no violation report for MC4.R15.1

Rule 15.2
Required
Decidable
Single T.U.

no violation report for MC4.R15.2

Rule 15.3
Required
Decidable
Single T.U.

no violation report for MC4.R15.3

Rule 15.4
Advisory
Decidable
Single T.U.

no violation report for MC4.R15.4

Rule 15.5
Disapplied
Decidable
Single T.U.

no violation report for MC4.R15.5

Rule 15.6
Required
Decidable
Single T.U.

no violation report for MC4.R15.6

Rule 15.7
Required
Decidable
Single T.U.

no violation report for MC4.R15.7

Rule 16.1
Required
Decidable
Single T.U.

no violation report for MC4.R16.1

Rule 16.2
Required
Decidable
Single T.U.

no violation report for MC4.R16.2

Rule 16.3
Required
Decidable
Single T.U.

no violation report for MC4.R16.3

Rule 16.4
Required
Decidable
Single T.U.

no violation report for MC4.R16.4

Rule 16.5
Required
Decidable
Single T.U.

no violation report for MC4.R16.5

Rule 16.6
Required
Decidable
Single T.U.

no violation report for MC4.R16.6

Rule 16.7
Required
Decidable
Single T.U.

no violation report for MC4.R16.7

Rule 17.1
Required
Decidable
Single T.U.

no violation report for MC4.R17.1

Rule 17.2
Required
Undecidable
System

no violation report or caution report for MC4.R17.2

Rule 17.3
Mandatory
Decidable
Single T.U.

no violation report for MC4.R17.3

Rule 17.4
Mandatory
Decidable
Single T.U.

no violation report for MC4.R17.4

Rule 17.5
Required
Undecidable
System

no violation report or caution report for MC4.R17.5

Rule 17.7
Required
Decidable
Single T.U.

no violation report for MC4.R17.7

Rule 17.8
Advisory
Undecidable
System

no violation report for MC4.R17.8

Rule 17.9
Mandatory
Undecidable
System

no violation report for MC4.R17.9

Rule 17.10
Required
Decidable
Single T.U.

no violation report for MC4.R17.10

Rule 17.11
Advisory
Undecidable
System

no violation report for MC4.R17.11

after: obtain 100% return point coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 17.12
Advisory
Decidable
Single T.U.

no violation report for MC4.R17.12

Rule 17.13
Required
Decidable
Single T.U.

no violation report for MC4.R17.13

Rule 18.1
Required
Undecidable
System

no violation report or caution report for MC4.R18.1

after: pointers subject to addition or subtraction should be checked

Rule 18.2
Required
Undecidable
System

no violation report or caution report for MC4.R18.2

Rule 18.3
Required
Undecidable
System

no violation report or caution report for MC4.R18.3

Rule 18.4
Advisory
Decidable
Single T.U.

no violation report or caution report for MC4.R18.4

Rule 18.5
Advisory
Decidable
Single T.U.

no violation report for MC4.R18.5

Rule 18.6
Required
Undecidable
System

no violation report or caution report for MC4.R18.6

Rule 18.7
Required
Decidable
Single T.U.

no violation report for MC4.R18.7

Rule 18.8
Required
Decidable
Single T.U.

no violation report for MC4.R18.8

Rule 18.9
Required
Decidable
Single T.U.

no violation report for MC4.R18.9

Rule 18.10
Mandatory
Decidable
Single T.U.

no violation report for MC4.R18.10

Rule 19.1
Mandatory
Undecidable
System

no violation report or caution report for MC4.R19.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 19.2
Advisory
Decidable
Single T.U.

no violation report for MC4.R19.2

Rule 19.3
Required
Undecidable
System

no violation report for MC4.R19.3

after: all union accesses to members that are proven to be written before being set can be deviated as described in the service documentation

Rule 20.1
Advisory
Decidable
Single T.U.

no violation report for MC4.R20.1

Rule 20.2
Required
Decidable
Single T.U.

no violation report for MC4.R20.2

Rule 20.3
Required
Decidable
Single T.U.

no violation report for MC4.R20.3

Rule 20.4
Required
Decidable
Single T.U.

no violation report for MC4.R20.4

Rule 20.5
Advisory
Decidable
Single T.U.

no violation report for MC4.R20.5

Rule 20.6
Required
Decidable
Single T.U.

no violation report for MC4.R20.6

Rule 20.7
Required
Decidable
Single T.U.

no violation report for MC4.R20.7

Rule 20.8
Required
Decidable
Single T.U.

no violation report for MC4.R20.8

Rule 20.9
Required
Decidable
Single T.U.

no violation report for MC4.R20.9

Rule 20.10
Advisory
Decidable
Single T.U.

no violation report for MC4.R20.10

Rule 20.11
Required
Decidable
Single T.U.

no violation report for MC4.R20.11

Rule 20.12
Required
Decidable
Single T.U.

no violation report for MC4.R20.12

Rule 20.13
Required
Decidable
Single T.U.

no violation report for MC4.R20.13

Rule 20.14
Required
Decidable
Single T.U.

no violation report for MC4.R20.14

Rule 20.15
Required
Decidable
Single T.U.

no violation report for MC4.R20.15

Rule 21.3
Required
Decidable
Single T.U.

no violation report for MC4.R21.3

Rule 21.4
Required
Decidable
Single T.U.

no violation report for MC4.R21.4

Rule 21.5
Required
Decidable
Single T.U.

no violation report for MC4.R21.5

Rule 21.6
Required
Decidable
Single T.U.

no violation report for MC4.R21.6

Rule 21.7
Required
Decidable
Single T.U.

no violation report for MC4.R21.7

Rule 21.8
Required
Decidable
Single T.U.

no violation report for MC4.R21.8

Rule 21.9
Required
Decidable
Single T.U.

no violation report for MC4.R21.9

Rule 21.10
Required
Decidable
Single T.U.

no violation report for MC4.R21.10

Rule 21.11
Advisory
Decidable
Single T.U.

no violation report for MC4.R21.11

Rule 21.12
Required
Decidable
Single T.U.

no violation report for MC4.R21.12

Rule 21.13
Mandatory
Undecidable
System

no violation report or caution report for MC4.R21.13

Rule 21.14
Required
Undecidable
System

no violation report or caution report for MC4.R21.14

Rule 21.15
Required
Decidable
Single T.U.

no violation report for MC4.R21.15

Rule 21.16
Required
Decidable
Single T.U.

no violation report for MC4.R21.16

Rule 21.17
Mandatory
Undecidable
System

no violation report or caution report for MC4.R21.17

after: recheck all uses of string handling functions

Rule 21.18
Mandatory
Undecidable
System

no violation report or caution report for MC4.R21.18

Rule 21.19
Mandatory
Undecidable
System

no violation report or caution report for MC4.R21.19

Rule 21.20
Mandatory
Undecidable
System

no violation report or caution report for MC4.R21.20

Rule 21.21
Required
Decidable
Single T.U.

no violation report for MC4.R21.21

Rule 21.22
Mandatory
Decidable
Single T.U.

no violation report for MC4.R21.22

Rule 21.23
Required
Decidable
Single T.U.

no violation report for MC4.R21.23

Rule 21.24
Required
Decidable
Single T.U.

no violation report for MC4.R21.24

Rule 21.25
Required
Decidable
Single T.U.

no violation report for MC4.R21.25

Rule 21.26
Required
Undecidable
System

no violation report for MC4.R21.26

Rule 22.1
Required
Undecidable
System

no violation report or caution report for MC4.R22.1

after: it should be checked that any resources obtained dynamically by means of standard library functions are released

Rule 22.2
Mandatory
Undecidable
System

no violation report or caution report for MC4.R22.2

after: any calls to free or realloc should be checked

Rule 22.3
Required
Undecidable
System

no violation report or caution report for MC4.R22.3

Rule 22.4
Mandatory
Undecidable
System

no violation report or caution report for MC4.R22.4

Rule 22.5
Mandatory
Undecidable
System

no violation report or caution report for MC4.R22.5

Rule 22.6
Mandatory
Undecidable
System

no violation report or caution report for MC4.R22.6

Rule 22.7
Required
Undecidable
System

no violation report for MC4.R22.7

after: any call that compares its return value with EOF and the test does not immediately follow the call should be checked

Rule 22.8
Required
Undecidable
System

no violation report or caution report for MC4.R22.8

Rule 22.9
Required
Undecidable
System

no violation report or caution report for MC4.R22.9

Rule 22.10
Mandatory
Undecidable
System

no violation report or caution report for MC4.R22.10

Rule 22.11
Required
Undecidable
System

no violation report for MC4.R22.11

Rule 22.12
Mandatory
Undecidable
System

no violation report for MC4.R22.12

Rule 22.13
Required
Decidable
Single T.U.

no violation report for MC4.R22.13

Rule 22.14
Mandatory
Undecidable
System

no violation report for MC4.R22.14

Rule 22.15
Required
Undecidable
System

no violation report for MC4.R22.15

Rule 22.16
Required
Undecidable
System

no violation report for MC4.R22.16

Rule 22.17
Required
Undecidable
System

no violation report for MC4.R22.17

Rule 22.18
Required
Undecidable
System

no violation report for MC4.R22.18

Rule 22.19
Required
Undecidable
System

no violation report for MC4.R22.19

Rule 22.20
Mandatory
Undecidable
System

no violation report for MC4.R22.20

Rule 23.1
Advisory
Decidable
Single T.U.

no violation report for MC4.R23.1

Rule 23.2
Required
Decidable
Single T.U.

no violation report for MC4.R23.2

Rule 23.3
Advisory
Decidable
Single T.U.

no violation report for MC4.R23.3

Rule 23.4
Required
Decidable
Single T.U.

no violation report for MC4.R23.4

Rule 23.5
Advisory
Decidable
Single T.U.

no violation report for MC4.R23.5

Rule 23.6
Required
Decidable
Single T.U.

no violation report for MC4.R23.6

Rule 23.7
Advisory
Decidable
Single T.U.

no violation report for MC4.R23.7

Rule 23.8
Required
Decidable
Single T.U.

no violation report for MC4.R23.8

The MISRA C:1998 Coding Rules

For the MISRA-C:1998 [60] coding rules, the exact definition takes into account all clarifications published in [61]. Note that for each of the supported MISRA-C:1998 rules, the identifier for the corresponding ECLAIR service is obtained by adding the prefix MC1., thereby obtaining, for example: MC1.1, MC1.49, MC1.113, …

Note that the page numbers included in the references to [60] in the ECLAIR service summaries are for the PDF version of [60] .

Rule MC1.1

Summary

All code shall conform to ISO 9899 standard C, with no extensions permitted. (See page 28 of MISRA-C-1998 [60] , page 2 of MISRA-C-1998-TCD [61] .)

Description

In particular, the following is reported:

  1. Each implementation-defined behavior defined by Annex G.3 in the C90 standard [34] that is not documented and not specifically addressed by other MISRA rules.

    • For each implementation-defined item, language and compiler, the project report will show a set of samples of code that have possibly implementation-defined behavior and a summary message.

    • The default number of reported samples is 1, but this can be changed using the behavior_sampling service configuration.

    • For clarification about the reporting of implementation-defined behavior, see page 106 of MISRA-C:2004 [62] Appendix B.

  2. Any code that is found to be ill-formed.

  3. Any breaching of the implementation’s limits (see the C90 standard [34] Section 5.2.4.1).

  4. Undefined or unspecified behavior as given by the C90 standard [34] Annex G. Note that:

    • there might be false negatives due to incomplete semantic information;

    • issues that are specifically addressed by other rules are not reported.

Imprecision

Cautions are reported when the precise behavior cannot be determined.

When the undefined or unspecified behavior item is undecidable, the related ancillary service reports possible non-compliance as a caution.

False negatives are reported when the checker precision is insufficient.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.anonstct STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.arthinvl STD.asrtterm STD.bincondl STD.bitfldby STD.bitfldor STD.bitfldtp STD.bitfwdth STD.blkident STD.bsercheq STD.bytebits STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charmult STD.charppif STD.charset STD.charstrl STD.charxwde STD.cissnest STD.cmntstle STD.cmpdltrl STD.cnstenum STD.datetime STD.decllimt STD.declmixd STD.decltype STD.defined STD.desginit STD.diag STD.diagidnt STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.encderor STD.enumlist STD.enumtype STD.eofnl STD.extident STD.flexaray STD.floatdem STD.floatnrw STD.fntpqual STD.forhdecl STD.fprscarg STD.fprscfmt STD.freesten STD.freestlb STD.freestnd STD.funojptr STD.funptrcv STD.hdrexpnd STD.hostmain STD.iddiflkg STD.iddollar STD.implfunc STD.inclexpd STD.inclfile STD.inclnest STD.indxcnst STD.indxvltl STD.intconvn STD.intfloat STD.intnlobj STD.ipconrep STD.linedir STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainargv STD.mainrtrn STD.membrecd STD.ncstinit STD.negshift STD.nodecltr STD.nonstdc STD.nullpntr STD.objbytes STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.prepdirc STD.pteincmp STD.ptrintcv STD.ptrnconv STD.ptypnest STD.qotemtch STD.qsortord STD.recdnest STD.redltype STD.register STD.rtrnemty STD.rvalsubs STD.shortsgn STD.stdcctxt STD.stdcprag STD.stdtypes STD.stmtexpr STD.strerror STD.strlitrl STD.tokenext STD.vaargast STD.volatltp STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC1.1,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC1.1,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC1.2

Summary

Code written in languages other than C should only be used if there is a defined interface standard for object code to which the compilers/assemblers for both languages conform. (See page 28 of MISRA-C-1998 [60] .)

Description

Note that compilers can be white-listed using the compilers service configuration.

Configuration

See generic service options.

Option compilers
compilers
-config=MC1.2,compilers=TOOL_MATCHER,...

Specify the tool tags; compilers are taken to be compatible if and only if they have the same tag.

The configuration’s content is a list of tags matching compatible compilers.

TOOL_MATCHER:

a -tool_tag identifier or a matcher expression whose matching compilers are all considered as compatible.


Rule MC1.3

Summary

Assembly language functions that are called from C should be written as C functions containing only in-line assembly language, and in-line assembly language should not be embedded in normal C code. (See page 28 of MISRA-C-1998 [60] , page 2 of MISRA-C-1998-TCD [61] .)

Description

A function is non-compliant if it contains an unencapsulated asm statement and a non-asm statement Notes:

  • Expressions and statements specified using the configuration parameters ignored_stmts service configurations are said to be ignored.

  • A macro that contains, other than ignored code, only asm statements is considered a valid asm encapsulator.

  • A function that contains, other than ignored code, only asm statements, possibly expanded from asm encapsulator macros, or calls to asm encapsulator functions is considered a valid asm encapsulator.

  • Any asm statements that are expanded from a macro or in a macro-defined do-while-zero loop idiom are ignored.

Configuration

See generic service options.

Option ignored_stmts
ignored_stmts
-config=MC1.3,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MC1.4

Summary

Provision should be made for appropriate run-time checking. (See page 29 of MISRA-C-1998 [60] .)

Description

The document service configuration should be used to specify, for each unexpected behavior kind where a documenting comment describing the countermeasures used for any possible runtime unexpected behavior, will be found together with its expected format.

The behavior kinds that are checked for documentation are:

  • overflow,

  • unexpected wrapping,

  • invalid shift,

  • division/remainder by zero,

  • unsequenced side effects,

  • read from uninitialized automatic object,

  • read from uninitialized allocated object,

  • write to string literal or const object,

  • non-volatile access to volatile object,

  • access to dead allocated object,

  • access to dead automatic object,

  • access to dead thread object,

  • access using null pointer,

  • access using invalid pointer,

  • access using out-of-bounds pointer,

  • access using unaligned pointer,

  • mistyped access to object,

  • mistyped access to function,

  • invalid pointer arithmetic,

  • invalid pointer comparison,

  • overlapping copy,

  • invalid arguments to function,

  • returned function error,

  • tainted input,

  • data race,

  • invariant violation,

  • communication error.

Using the default value for document valid documentation comments look like:

/* Documentation for MISRA-C:1998 Rule 4: overflow ... To Be Written ... */
/* Documentation for MISRA-C:1998 Rule 4: unexpected wrapping ... To Be Written ... */
/* Documentation for MISRA-C:1998 Rule 4: invalid shift ... To Be Written ... */
/* ... */
/* Documentation for MISRA-C:1998 Rule 4: communication error ... To Be Written ... */

These special comments should be placed in a compiled file, otherwise, ECLAIR will not be able to detect them. For each of them the ... To Be Written ... should be replaced with the description of what is done to minimize the risk or why the situation cannot happen or is not relevant for the project.

Configuration

See generic service options.

Option document
document
-config=MC1.4,document={ID_FMT, SUB, FILE_MATCHER, WHAT, DOC_FMT, REP_FMT},...

Specify how to extrapolate the required documentation from comments in the specified compiled source files.

The configuration’s content is a list of tuples that provide (in order) a unique identifier for the document, context and file matcher indicating where to search for the document, what to check for (e.g., missing documentation), a format for matcher to check the documentation content and a format for the reports.

ID_FMT:

format (see the -fmt global configuration content, template userdocs__id_default_fmt) for short but unique name to identify the document with field:

service

service name.

SUB:

tag indicating subject. Accepted values are:

  • unit: check all files for each translation unit;

  • file: check each file;

  • program: check all the program files;

  • project: check all the project files;

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

WHAT:

tag indicating what to report. Accepted values are:

  • duplicates: report if more than one matching document is found;

  • missing: report if no documentation is found;

  • missing_if_noted: report if no documentation is found and uses are noted;

  • all: report any duplicated or missing documentation;

  • none: do not report missing or duplicated documentation;

DOC_FMT:

format (see the -fmt global configuration content, template userdocs__document_default_fmt) specifying regular expression to match the document content with fields:

document_id

a document identifier;

file

canonical pathname;

rule

rule description;

service

service name.

REP_FMT:

format (see the -fmt global configuration content, template userdocs__default_fmt) for message to be included in the report with fields:

document_id

a document identifier;

file

canonical pathname;

error

message indicating the error kind which can be missing_file, missing_docs or duplicate_docs;

target

unit, program or project description;

service

service name.

Default:

-config=MC1.4,document={"%{__overflow_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__wrapping_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__shift_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__division_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__side_effects_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__write_to_const_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__non_volatile_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_thread_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__null_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__bounds_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__unaligned_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_object_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_function_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_arith_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_compare_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__overlap_copy_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_fun_args_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__return_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__tainted_input_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__data_race_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invariant_viol_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__comms_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"}

Option ignored_comments
ignored_comments
-config=MC1.4,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC1.5

Summary

Only those characters and escape sequences which are defined in the ISO C standard shall be used. (See page 30 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.6

Summary

Values of character types shall be restricted to a defined and documented subset of ISO 10646-1. (See page 30 of MISRA-C-1998 [60] , page 2 of MISRA-C-1998-TCD [61] .)

Description

Notes:

  • any character sets for coding and execution may be used, provided they are documented;

  • the STD.charsmap behavior, STD.charsmem behavior and the STD.charsval behavior service configurations can be used to specify the documentation;

  • for each non-standard or unspecified character used, the report will show samples with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

Imprecision

Cautions are reported when the behavior cannot be determined and the related ancillary service reports possible non-compliance as a caution.

This service depends upon the configuration of the following ancillary services: STD.charsmap STD.charsmem STD.charsval

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC1.6,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC1.6,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC1.6,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC1.7

Summary

Trigraphs shall not be used. (See page 30 of MISRA-C-1998 [60] , page 2 of MISRA-C-1998-TCD [61] .)

Description

Note that trigraphs are denoted by one of the sequences ??=, ??(, ??<, ??/, ??), ??>, ??', ??|, and ??-.

Configuration

See generic service options.

Rule MC1.8

Summary

Multibyte characters and wide string literals shall not be used. (See page 30 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=MC1.8,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MC1.9

Summary

Comments shall not be nested. (See page 31 of MISRA-C-1998 [60] , page 2 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option comments
comments
-config=MC1.9,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=MC1.9,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC1.10

Summary

Sections of code should not be “commented out”. (See page 31 of MISRA-C-1998 [60] , page 3 of MISRA-C-1998-TCD [61] .)

Description

Any non-compiled sources are reported as additional information.

Note that, by default, doxygen comments are ignored; this can be changed using the comments service configuration.

Implementation

A comment is non-compliant if it looks like code. That is, a comment is reported if a statistical measure (based on the total number of tokens and number of keywords and operators) is exceeded.

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

There exists no way to distinguish code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

/* This is a comment */

Configuration

See generic service options.

Option comments
comments
-config=MC1.10,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=MC1.10,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=MC1.10,code_lines=0

Option ignored_comments
ignored_comments
-config=MC1.10,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC1.10,ignored_comments=__doxygen_comments

Rule MC1.11

Summary

Identifiers (internal and external) shall not rely on significance of more than 31 characters. Furthermore the compiler/linker shall be checked to ensure that 31 character significance and case sensitivity are supported for external identifiers. (See page 31 of MISRA-C-1998 [60] .)

Description

Notes:

  • that this applies across all namespaces (see page 10 of MISRA-C:2004 TC1 [63] ).

  • The number of significant initial characters supported by the implementation in an external identifiers can be changed with the STD.extidsig behavior service configuration.

  • The number of significant initial characters supported by the implementation in non-external identifiers (internal identifiers, macro names and macro parameter names) can be changed with the option STD.nexidsig behavior.

This service depends upon the configuration of the following ancillary services: STD.extidsig STD.nexidsig

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC1.11,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC1.11,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.12

Summary

No identifier in one name space shall have the same spelling as an identifier in another name space. (See page 32 of MISRA-C-1998 [60] , page 3 of MISRA-C-1998-TCD [61] .)

Description

The summarize_max service configuration provides an alternative so that, instead of marking all instances of an identifier’s reuse, the rule reports a specified number of such instances as well as the total number of times the name of the identifier is used.

Configuration

See generic service options.

Option summarize_max
summarize_max
-config=MC1.12,summarize_max=MAX

Specify the maximum number of clashes to be shown.

MAX:

if Max = -1 or the number of clashes for an identifier is less than or equal to Max, then all the clashes are shown. Otherwise only Max clashes are shown and a program summary will show the total number of clashes for that identifier. It must be an integer greater than or equal to -1.

Default:

-config=MC1.12,summarize_max=0

Option reuse_by_location
reuse_by_location
-config=MC1.12,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC1.12,reuse_by_location=address

Rule MC1.13

Summary

The basic types of char, int, short, long, float and double should not be used, but specific-length equivalents should be typedef‘d for the specific compiler, and these type names used in the code. (See page 32 of MISRA-C-1998 [60] , page 3 of MISRA-C-1998-TCD [61] .)

Description

Taking the proposal for the typedef names in the normative text for MISRA Rule 6.3 on page 37 of MISRA-C:2004 [62] as the default schema, the typedef name is non-compliant if it does not have one of the following forms (where @BITS@ is replaced by the length in bits):

  • signed integer type - int@BITS@_t,

  • unsigned integer type - uint@BITS@_t,

  • floating type - float@BITS@_t.

The naming service configuration can be used to change this schema.

Configuration

See generic service options.

Option naming
naming
-config=MC1.13,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MC1.13,naming=misra_1

Option declarations
declarations
-config=MC1.13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC1.13,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC1.14

Summary

The type char shall always be declared as unsigned char or signed char. (See page 33 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option types
types
-config=MC1.14,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MC1.14,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.15

Summary

Floating point implementations should comply with a defined floating point standard. (See page 33 of MISRA-C-1998 [60] , page 4 of MISRA-C-1998-TCD [61] .)

Description

The STD.floatstd behavior service configuration can be used to specify the documentation.

The default number of reported samples for use of floating point types is 1, but this can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.floatstd

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC1.15,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC1.15,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC1.15,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC1.16

Summary

The underlying bit representations of floating point numbers shall not be used in any way by the programmer. (See page 33 of MISRA-C-1998 [60] , page 4 of MISRA-C-1998-TCD [61] .)

Description

To be more specific, the rule will report:

  1. if there is a type conversion between a pointer to a floating type and a pointer to any different type, with the following exceptions:

    • the conversion is from/to void*,

    • the conversion maps a pointer to (array of) floating type to a pointer to (array of) the same floating type, where the number and size of array constructions may differ;

  2. any object declaration with union type that has a member with floating-point type;

  3. any object declaration with a (possibly recursive) struct type that has a single member with union type and this has a member of floating-point type;

  4. if a union type with a member of floating-point type is referred to by a compound literal expression.

Imprecision

False positives are reported because the checker may not be sure if there is access to the memory area where a floating point object is stored.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.16,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option casts
casts
-config=MC1.16,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC1.17

Summary

typedef names shall not be reused. (See page 33 of MISRA-C-1998 [60] , page 4 of MISRA-C-1998-TCD [61] .)

Description

This rule does not report when:

  • the other entity is a typedef or;

  • both typedefs have the same declaration in the same header file, and the file is included in multiple source files.

Note also that the typedef name must not be used for any macro or macro parameter.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MC1.17,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC1.17,reuse_by_location=address

Rule MC1.18

Summary

Numeric constants should be suffixed to indicate type, where an appropriate suffix is available. (See page 34 of MISRA-C-1998 [60] , page 4 of MISRA-C-1998-TCD [61] .)

Description

Thus, for example, if a constant is used to initialize an object declared as an unsigned int or used as an operand in an expression where its type after the usual arithmetic conversions is unsigned int, then it is reported if it does not have the suffix U.

Notes:

  • the context in which the constant is used is relevant (see the example on page 34 of MISRA-C:1998 [60] );

  • the suffixes L and l are both allowed although the uppercase L is recommended (see the note on page 4 of MISRA-C:1998 TCD [61] );

  • the inferred type for the integer constants is based on the table on page 56 of the C99 standard [37];

  • the inferred types of the preprocessor constants are based on the C99 standard [37] types intmax_t and uintmax_t;

  • it is also reported if a value is too large for the type of the context.

Configuration

See generic service options.

Option literals
literals
-config=MC1.18,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Option preproc_literal_syntax
preproc_literal_syntax
-config=MC1.18,preproc_literal_syntax=BOOL

A Boolean parameter indicating whether the integer constants in the controlling expressions of #if and #elif preprocessing directives should be checked.

BOOL:

if value is true, then the integer constants will be checked. Accepted values are:

  • false: the integer constants will not be checked;

  • true: the integer constants will be checked;

Default:

-config=MC1.18,preproc_literal_syntax=true

Rule MC1.19

Summary

Octal constants (other than zero) shall not be used. (See page 34 of MISRA-C-1998 [60] .)

Exceptions

The integer constant 0 and the octal escape sequence \0 are allowed.

Configuration

See generic service options.

Option literals
literals
-config=MC1.19,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MC1.20

Summary

All object and function identifiers shall be declared before use. (See page 35 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option statements
statements
-config=MC1.20,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.20,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.21

Summary

Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier. (See page 35 of MISRA-C-1998 [60] , page 4 of MISRA-C-1998-TCD [61] .)

Description

Note that here we adopt the meaning of scope as defined in the normative text for the corresponding MISRA Rule 5.2 on page 34 of MISRA-C:2004 [62] : identifiers that have file scope are considered as having the outermost scope. Identifiers that have block scope have a more inner scope. Successive, nested blocks, introduce more inner scopes.

Configuration

See generic service options.

Rule MC1.22

Summary

Declarations of objects should be at function scope unless a wider scope is necessary. (See page 35 of MISRA-C-1998 [60] , page 4 of MISRA-C-1998-TCD [61] .)

Description

More specifically, reports a variable if all the following hold:

  • the variable has linkage;

  • it is referenced;

  • all references to it are in the same function;

  • if it is a variable with external linkage, then all references are in the same unit.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.22,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.23

Summary

All declarations at file scope should be static where possible. (See page 36 of MISRA-C-1998 [60] .)

Description

More specifically, reports a function or variable if all the following hold:

  • it is referenced;

  • it is declared at file scope;

  • if it is a variable with external linkage, then all references are in the same unit;

  • it is not explicitly declared static.

Configuration

See generic service options.

Option definition_in_same_unit
definition_in_same_unit
-config=MC1.23,definition_in_same_unit=BOOL

Specify if the definition must be in the same translation unit as the references.

BOOL

Accepted values are:

  • true: the definition must be in the same translation unit as the references;

  • false: the definition does not have to be in the same translation unit as the references;

Default:

-config=MC1.23,definition_in_same_unit=true

Option declarations
declarations
-config=MC1.23,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.24

Summary

Identifiers shall not simultaneously have both internal and external linkage in the same translation unit. (See page 36 of MISRA-C-1998 [60] , page 5 of MISRA-C-1998-TCD [61] .)

Description

Notes:

It is not clear from the rule’s summary what should be checked. However Appendix B, page 107 of MISRA-C:2004 [62] indicates that this rule corresponds to rule 8.11.

The example in MISRA Rule 24 on page 36 of MISRA-C:1998 [60] does not parse and it is corrected on page 5 of MISRA-C:1998 TCD [61] .

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.24,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.25

Summary

An identifier with external linkage shall have exactly one external definition. (See page 36 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.25,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.26

Summary

If objects or functions are declared more than once they shall have compatible declarations. (See page 36 of MISRA-C-1998 [60] .)

Description

More specifically:

  • if a variable is declared more than once, the types must be compatible;

  • if a function has more than one prototype declaration or definition, the corresponding parameter types or return types must be compatible.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.26,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.27

Summary

External objects should not be declared in more than one file. (See page 37 of MISRA-C-1998 [60] , page 5 of MISRA-C-1998-TCD [61] .)

Description

Note that a header file is assumed to be any file that is included via the #include directive, regardless of name or suffix.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.27,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.28

Summary

The register storage class specifier should not be used. (See page 37 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.28,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.29

Summary

The use of a tag shall agree with its declaration. (See page 37 of MISRA-C-1998 [60] , page 5 of MISRA-C-1998-TCD [61] .)

Description

The rule does not report when:

  • the other entity is a tag name or;

  • both the tag names have the same declaration in the same header file, and the file is included in multiple source files.

Note also that the tag name must not be used for any macro or macro parameter.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MC1.29,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC1.29,reuse_by_location=address

Rule MC1.30

Summary

All automatic variables shall have been assigned a value before being used. (See page 37 of MISRA-C-1998 [60] .)

Description

Note that this does not necessarily require initialization at the declaration.

Note also that initializing any one member of a union is not considered as (proper) initialization of the other members.

Implementation

Reports if an automatic variable may be used without initialization.

Imprecision

Cautions are reported when the analyzer cannot determine the necessary execution order.

Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}

Configuration

See generic service options.

Option member_areas
member_areas
-config=MC1.30,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=MC1.30,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MC1.30,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.31

Summary

Braces shall be used to indicate and match the structure in the non-zero initialisation of arrays and structures. (See page 38 of MISRA-C-1998 [60] .)

Description

Reports the zero initialization unless it is at the top level and non-empty.

The length of string literals in character array initializers is not checked.

Configuration

See generic service options.

Rule MC1.32

Summary

In an enumerator list, the = construct shall not be used to explicitly initialise members other than the first, unless all items are explicitly initialised. (See page 38 of MISRA-C-1998 [60] .)

Description

More specifically, each enumeration initializer must satisfy one of the following:

  • none of the enumeration constants are initialised;

  • only the first enumeration constant is initialised;

  • all the enumeration constants are explicitly initialised.

In addition, the expression that defines the value of an enumeration constant must be an integral constant expression that has a value representable as an int; also in the case that only the first enumeration constant is initialised, the value must be small enough so that no subsequent value in the list will exceed the int storage used by enumeration constants (See Section 6.5.2.2 of the C90 standard [34]).

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.32,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.33

Summary

The right hand operand of a && or || operator shall not contain side effects. (See page 39 of MISRA-C-1998 [60] .)

Description

It is assumed that a call to a function has side effects unless the call is declared to have impact property const, pure or noeffect.

The -call_properties global configuration can be used to specify the call property. For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when the right operand is a call to a function not declared to be noeffect.

Configuration

See generic service options.

Option effects
effects
-config=MC1.33,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC1.34

Summary

The operands of a logical && or || shall be primary expressions. (See page 39 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MC1.34,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MC1.35

Summary

Assignment operators shall not be used in expressions which return Boolean values. (See page 39 of MISRA-C-1998 [60] , page 6 of MISRA-C-1998-TCD [61] .)

Description

Reports any use of a simple or compound assignment operator:

  • as an operand of &&, ||, !, <, <=, >, >=, ==, or !=;

  • in the condition part of the :? operator;

  • or in the condition part of an if, do, for, or while statement.

Configuration

See generic service options.

Option statements
statements
-config=MC1.35,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.35,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.36

Summary

Logical operators should not be confused with bitwise operators. (See page 40 of MISRA-C-1998 [60] , page 6 of MISRA-C-1998-TCD [61] .)

Description

Therefore:

  1. operands of logical operators must have effectively Boolean types;

  2. the operands of bitwise and arithmetic operators must have non-Boolean types;

  3. Initializers for non-Boolean types must not have effectively Boolean types.

Note that this rule does not report a bitwise operator that is in a context requiring an effectively Boolean value since this will be reported by Rule MC1.49.

Configuration

See generic service options.

Option etypes
etypes
-config=MC1.36,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC1.37

Summary

Bitwise operations shall not be performed on signed integer types. (See page 40 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option statements
statements
-config=MC1.37,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.37,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.38

Summary

The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the left hand operand (inclusive). (See page 40 of MISRA-C-1998 [60] .)

Description

All the expressions and the conditional expressions are checked.

Implementation

Any shift operator (<<, >>) is non-compliant if:

  • it is in the object sources and either the right-hand side is a non-constant expression or its value is a known constant value that is negative or is greater than or equal to the width in bits of the promoted type of the left-hand side; or

  • it is in the non-skipped compiled file contents in a preprocessor conditional expressions and either the right-hand side is unexpanded or its value is negative or greater than or equal to the width in bits of the promoted type of the left-hand side.

Imprecision

Cautions are reported when non-constant values are on the right-hand side of a shift operator.

Configuration

See generic service options.

Rule MC1.39

Summary

The unary minus operator shall not be applied to an unsigned expression. (See page 41 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option statements
statements
-config=MC1.39,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.39,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.40

Summary

The sizeof operator should not be used on expressions that contain side effects. (See page 41 of MISRA-C-1998 [60] , page 6 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option effects
effects
-config=MC1.40,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC1.41

Summary

The implementation of integer division in the chosen compiler should be determined, documented and taken into account. (See page 41 of MISRA-C-1998 [60] .)

Description

Notes:

  • the STD.divrmsgn behavior service configuration should be used to specify the expected direction of rounding when dividing two signed integers;

  • the report will show a sample use of integer division with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.divrmsgn

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC1.41,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC1.41,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC1.41,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC1.42

Summary

The comma operator shall not be used, except in the control expression of a for loop. (See page 41 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option statements
statements
-config=MC1.42,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.42,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.43

Summary

Implicit conversions which may result in a loss of information shall not be used. (See page 42 of MISRA-C-1998 [60] , page 6 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option casts
casts
-config=MC1.43,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC1.44

Summary

Redundant explicit casts should not be used. (See page 42 of MISRA-C-1998 [60] , page 7 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option casts
casts
-config=MC1.44,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC1.45

Summary

Type casting from any type to or from pointers shall not be used. (See page 42 of MISRA-C-1998 [60] , page 7 of MISRA-C-1998-TCD [61] .)

Exceptions

The following operations are allowed:

  • conversions from pointer to void* or vice-versa;

  • pointer decays;

  • pointer qualifications;

  • null pointer buildings.

Configuration

See generic service options.

Option casts
casts
-config=MC1.45,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC1.46

Summary

The value of an expression shall be the same under any order of evaluation that the standard permits. (See page 43 of MISRA-C-1998 [60] , page 8 of MISRA-C-1998-TCD [61] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule MC1.47

Summary

No dependence should be placed on C’s operator precedence rules in expressions. (See page 45 of MISRA-C-1998 [60] , page 8 of MISRA-C-1998-TCD [61] .)

Description

Reports an expression:

  • if the expression has the form E0 OP E1 OPEn OP, the operator OP is the builtin + or *, and the types T0, …, Tn of expressions E0, …, En are as follows:

    • T0, …, Tn are promoted to integral types I0, …, In, in { unsigned long long, long long, unsigned long, long, unsigned int, int {}}, the first type in the above sequence that is in I0, …, In is Ii, and there are two or more types in I0, …, In that are strictly later in the sequence than Ii; or

    • one of T0, …, Tn is non-integral;

  • if the expression has the form E0 OP1 E1 OP2 E2 where OP1 and OP2 are assignment operators;

  • if the expression has the form E0 OP E1 OP E2 where OP is a relational, equality, logical or arithmetic operator other than +, *, &&, ||, &, |, ^;

  • if the expression has the form E0 OP1 E1 OP2 E2 where OP1 is a relational, equality, logical or arithmetic operator, OP2 is any binary operator and OP1 differs from OP2;

  • if the expression has the form E0 OP E1 where OP is any binary operator and E0 or E1 are unary operator expressions except for function call and array subscript expressions;

  • if the expression is conditional and one of the sub-expressions is a conditional or a binary expression.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MC1.47,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MC1.48

Summary

Mixed precision arithmetic should use explicit casting to generate the desired result. (See page 45 of MISRA-C-1998 [60] , page 8 of MISRA-C-1998-TCD [61] .)

Description

  • The casted type class (signed, unsigned, floating) of an operator should be the same as its uncasted operands;

  • The operator result should not be implicitly casted to a wider type;

  • A non-constant operator result should not be explicitly cast to a wider type.

Configuration

See generic service options.

Rule MC1.49

Summary

Tests of a value against zero should be made explicit, unless the operand is effectively Boolean. (See page 46 of MISRA-C-1998 [60] , page 9 of MISRA-C-1998-TCD [61] .)

Description

Any expression that does not have a Boolean type must not be used in any of the following ways:

  • as an operand of &&, ||, !, <, <=, > or >=>;

  • in the condition part of the :? operator;

  • in the condition part of an if, do, for, or while statement;

  • is cast (implicitly or explicitly) to a Boolean type.

The rule ignores the integer literal 0 when used for the condition part of a macro-expanded do-while-zero.

Configuration

See generic service options.

Option etypes
etypes
-config=MC1.49,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC1.50

Summary

Floating point variables shall not be tested for exact equality or inequality. (See page 46 of MISRA-C-1998 [60] , page 9 of MISRA-C-1998-TCD [61] .)

Exceptions

Note that comparison with 0.0 can be exempted using the statements service configuration.

Imprecision

false negatives are present because recognising indirect equality and inequality tests is undecidable

Configuration

See generic service options.

Option statements
statements
-config=MC1.50,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option ignored_stmts
ignored_stmts
-config=MC1.50,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MC1.51

Summary

Evaluation of constant unsigned integer expressions should not lead to wrap-around. (See page 46 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.52

Summary

There shall be no unreachable code. (See page 47 of MISRA-C-1998 [60] , page 9 of MISRA-C-1998-TCD [61] .)

Description

The rule reports:

  • defined functions that are not referenced;

  • unreachable code;

  • constant unfeasible code.

Notes:

  • unreferenced static, inline functions are not reported.

  • the MISRA forum thread “14.1 There shall be no unreachable code” confirms that this rule is only concerned with code for which the syntax does not permit it to be accessed.

  • A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

  • Reports for deliberately unreachable statements and expressions can be tagged using the statements service configuration.

  • Unused declarations can be tagged using the declarations service configuration; in particular, to hide declarations in public API files by:

    • using the tag hide;

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library entry points not necessarily have to be referenced."
-config=MC1.52,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Imprecision

False negatives are present because whether code is unreachable is undecidable.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.52,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_stmts
ignored_stmts
-config=MC1.52,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option statements
statements
-config=MC1.52,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option all_decls
all_decls
-config=MC1.52,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option diagnostics
diagnostics
-config=MC1.52,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MC1.53

Summary

All non-null statements shall have a side-effect. (See page 47 of MISRA-C-1998 [60] , page 11 of MISRA-C-1998-TCD [61] .)

Description

Notes:

  • the side effect must be caused by the external operator/functor of the expression (and not just an effect of its sub-expressions);

  • explicit cast to void is not reported (see the corresponding Rule 2.2 on page 41 of MISRA C:2012 [45] ).

Imprecision

False positives are reported when there are function calls and it is not known if the called function has side effects.

Configuration

See generic service options.

Rule MC1.54

Summary

A null statement shall only occur on a line by itself, and shall not have any other text on the same line. (See page 47 of MISRA-C-1998 [60] , page 11 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Rule MC1.55

Summary

Labels should not be used, except in switch statements. (See page 47 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option statements
statements
-config=MC1.55,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.55,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.56

Summary

The goto statement shall not be used. (See page 47 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option statements
statements
-config=MC1.56,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.56,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.57

Summary

The continue statement shall not be used. (See page 47 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option statements
statements
-config=MC1.57,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.57,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.58

Summary

The break statement shall not be used (except to terminate the cases of a switch statement). (See page 47 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.59

Summary

The statements forming the body of an if, else if, else, while, do ... while or for statement shall always be enclosed in braces. (See page 48 of MISRA-C-1998 [60] , page 11 of MISRA-C-1998-TCD [61] .)

Description

Notes:

  • any do, for, or while statement must have its body enclosed in braces;

  • any switch statement must have its body enclosed in braces (see the note on page 11 of MISRA-C:1998 TCD [61] );

  • in an if statement, the condition part must be immediately followed by a compound statement;

  • any else keyword must be followed by another if statement or by a compound statement.

Configuration

See generic service options.

Rule MC1.60

Summary

All if, else if constructs should contain a final else clause. (See page 48 of MISRA-C-1998 [60] .)

Description

The if statement is reported if the final else if:

  • has no else clause;

  • is the null statement;

  • is an empty compound statement that does not contain a suitable comment as to why no action is taken.

The default configuration does not check the content or style of the comment; however the else_empty service configuration can be used to provide a comment matcher.

Configuration

See generic service options.

Option else_empty
else_empty
-config=MC1.60,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC1.60,else_empty={missing, "none()"}, {null, "none()"}, {empty_compound, "any()"}

Option ignored_comments
ignored_comments
-config=MC1.60,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC1.61

Summary

Every non-empty case clause in a switch statement shall be terminated with a break statement. (See page 49 of MISRA-C-1998 [60] , page 11 of MISRA-C-1998-TCD [61] .)

Description

Note that in the introductory text for Section 6.15 on page 71 of MISRA-C:2004 [62] , a case or default clause is defined to be the sequence of statements (excluding any case or default label statements) starting with the case or default label statement and finishing at the next case or default statement or at the end of the compound statement forming the body of a switch statement.

For terminating statements other than break, the reports can be tagged by means of the terminals service configuration.

For example, with the configure line:

-doc="Terminals statements with a noreturn function are safe."
-config=MC1.61,terminals={safe,"call(property(noreturn))"}

if the last statement of the case or default clause is a call to a function with the noreturn property, then the report will have the tag safe.

Configuration

See generic service options.

Option terminals
terminals
-config=MC1.61,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MC1.61,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC1.61,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC1.62

Summary

All switch statements should contain a final default clause. (See page 49 of MISRA-C-1998 [60] , page 12 of MISRA-C-1998-TCD [61] .)

Description

A comment may be used in place of the default clause. To specify the allowed form of the comment use the replacement_comment service configuration.

For example, with the configuration line:

-doc="Only Fall through to next statement comments are accepted in place of the default clause."
-config=MC1.62,
  +replacement_comment={missing_terminal,
    "^.*([fF]all[- ]?[tT]hr(ough|u)|FALL[- ]?THR(OUGH|U))(s?).*$"}

This service will accept comments such as

Fall through to next statement

but not other comments such as

no default needed

as acceptible alternatives to a default clause.

Configuration

See generic service options.

Option replacement_comment
replacement_comment
-config=MC1.62,replacement_comment={WHEN, COMMENT_MATCHER},...

Specify matchers for replacement comments.

The configuration’s content is a list of pairs indicating when a comment is needed and a comment matcher.

WHEN:

when to check a comment replacement. Accepted values are:

  • empty_default: switch default clause is empty;

  • missing_terminal: case or default clause has no terminal statement;

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC1.62,replacement_comment={empty_default, "any()"}

Option switch_clauses
switch_clauses
-config=MC1.62,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC1.62,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC1.63

Summary

A switch expression should not represent a Boolean value. (See page 49 of MISRA-C-1998 [60] , page 12 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MC1.63,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Option declarations
declarations
-config=MC1.63,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.64

Summary

Every switch statement shall have at least one case. (See page 49 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.64,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.65

Summary

Floating point variables shall not be used as loop counters. (See page 50 of MISRA-C-1998 [60] , page 12 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option for_counter
for_counter
-config=MC1.65,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Rule MC1.66

Summary

Only expressions concerned with loop control should appear within a for statement. (See page 50 of MISRA-C-1998 [60] , page 12 of MISRA-C-1998-TCD [61] .)

Description

The three expressions of a for statement:

  • must all be present; or

  • must all be empty; or

  • the first expression is empty (and the loop counter is already initialised) and the second and third expressions are present.

There must be a single non-global numeric loop counter that occurs in a test in the condition part and modified in the after part.

The condition part must be a Boolean expression.

The after part must only modify the counter.

Note that if the for statement has a non-compliant structure, then the report can be tagged using for_structure service configuration. For example:

-doc="Non-compliant for with non-empty before part and non empty loop condition."
-config=MC1.66,for_structure={struct_tag,
    "before(non_empty)&&cond(non_empty)"}

will tag the violation report for a for statement that has an empty third expression in the head.

The conditions for a for statement where at least the second and third expressions are non-empty depend on the concept of a loop counter and on the more general concept of a control variable. These are defined as follows:

  • a control variable is any variable, array subscript expression, or member expression that has scalar type and is declared or referred to in the first expression;

  • a control variable is s loop counter if:

    • its type is integral,

    • it is not an array subscript expression or member expression (i.e., a variable),

    • it is initialized in the first expression or initialized prior to the for statement,

    • it is referenced in the second expression,

    • it is modified in the third expression,

    • it is not global,

    • there is only one loop counter.

Note that if the loop counter is non-compliant or there is more than one loop counter, then the report relating to this can be tagged using for_counter service configuration. For example:

-doc="Non-compliant for with multiple counters."
-config=MC1.66,for_counter+={multi_tag, "(!single())"}}

will tag the violation report for a for statement that has more than one loop counter.

The three expressions of a for statement must satisfy the following conditions:

  • the first expression may only be used for initialising the loop counter;

  • the second expression is a non-empty boolean combination of tests (tests can be direct) and function calls that refer to the loop counter

  • the third expression must only modify the loop counter; no other control variable is modified;

Note that if any of the components of a for statement are non-compliant, then the report relating to the components can be tagged using for_parts service configuration. For example:

-doc="Non-compliant for with a before part that initializes more than one varible."
-config=MC1.66,for_parts={only_init_tag, "before(only_init)"}

will tag the violation report for a for statement when the first part of the head initializes (by means of assignments or definitions) more than one variable (assuming that the structure and loop counter are compliant).

Imprecision

Cautions are reported when the checker is uncertain whether the loop counter conditions are fully satisfied.

Configuration

See generic service options.

Option for_structure
for_structure
-config=MC1.66,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=MC1.66,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=MC1.66,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MC1.67

Summary

Numeric variables being used within a for loop for iteration counting should not be modified in the body of the loop. (See page 50 of MISRA-C-1998 [60] , page 13 of MISRA-C-1998-TCD [61] .)

Description

A loop counter is a variable that is modified in the last part of the for statement head.

If it cannot be proved that a numeric loop counter in a for statement is not be modified in the loop body or its address is not taken in the function body, then the loop counter will be reported.

Imprecision

Cautions are reported when the checker is uncertain whether the loop counter conditions are fully satisfied.

Configuration

See generic service options.

Rule MC1.68

Summary

Functions shall always be declared at file scope. (See page 50 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.68,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.69

Summary

Functions with variable numbers of arguments shall not be used. (See page 51 of MISRA-C-1998 [60] .)

Description

Reports:

  • user-defined functions whose declarations and definitions use ellipsis;

  • any #include with stdarg.h;

  • any uses of the standard library functions or function-like macros va_arg, va_start and va_end.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.69,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC1.69,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.70

Summary

Functions shall not call themselves, either directly or indirectly. (See page 51 of MISRA-C-1998 [60] .)

Description

For any function that is non-compliant, the report will show all calls in the chain that lead to it calling itself.

Imprecision

Cautions are reported when the recursion relies on indirect function calls to form the chain.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.70,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=MC1.70,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule MC1.71

Summary

Functions shall always have prototype declarations and the prototype shall be visible at both the function definition and call. (See page 51 of MISRA-C-1998 [60] .)

Description

Reports:

  • a function declaration or definition that does not have a function prototype;

  • a reference to a function before a prototype declaration or definition of the function;

  • a function defined in the compilation main file that has a previous prototype declaration that is located in a header file.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.71,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.72

Summary

For each function parameter the type given in the declaration and definition shall be identical, and the return types shall also be identical. (See page 51 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Description

Note that function definitions without a prototype declaration are not checked.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.72,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.73

Summary

Identifiers shall either be given for all of the parameters in a function prototype declaration, or for none. (See page 51 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.73,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.74

Summary

If identifiers are given for any of the parameters, then the identifiers used in the declaration and definition shall be identical. (See page 51 of MISRA-C-1998 [60] .)

Description

Note that missing identifiers are ignored by this rule.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.74,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.75

Summary

Every function shall have an explicit return type. (See page 51 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.75,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.76

Summary

Functions with no parameters shall be declared with parameter type void. (See page 51 of MISRA-C-1998 [60] .)

Description

Note that this rule does not report function pointers (see the note in the MISRA forum thread “Rule 16.5”.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.76,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.77

Summary

The unqualified type of parameters passed to a function shall be compatible with the unqualified expected types defined in the function prototype. (See page 52 of MISRA-C-1998 [60] .)

Description

For this service, types match when

  • they have the same pointee depth and the innermost non-pointer types, without qualifiers, are compatible;

  • the conversion is a pointer decay;

  • the conversion is a null pointer to pointer.

Configuration

See generic service options.

Option casts
casts
-config=MC1.77,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC1.78

Summary

The number of parameters passed to a function shall match the function prototype. (See page 52 of MISRA-C-1998 [60] .)

Description

Reports:

  • if there is no explicit declaration,

  • if there is a declaration but no prototype declaration, or

  • if there is a prototype declaration and the number of arguments passed to the function does not match the number of parameters.

Configuration

See generic service options.

Option calls
calls
-config=MC1.78,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=MC1.78,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.79

Summary

The values returned by void functions shall not be used. (See page 52 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.80

Summary

Void expressions shall not be passed as function parameters. (See page 52 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.81

Summary

const qualification should be used on function parameters which are passed by reference, where it is intended that the function will not modify the parameter. (See page 52 of MISRA-C-1998 [60] .)

Description

Note that the function main is never reported.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=MC1.81,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=MC1.81,show_declarations=all

Option declarations
declarations
-config=MC1.81,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MC1.81,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MC1.81,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MC1.82

Summary

A function should have a single point of exit. (See page 53 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Description

It is reported if a function does not have a single point of exit at the end of the function block. Notes:

  • what constitutes a function exit node can be specified by means of the exit_kind service configuration;

  • what constitutes an end position of a function can be specified by mean of the end_position service configuration.

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=MC1.82,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=MC1.82,exit_kind={return, only_at_end_position, true},
  {noreturn_call, anywhere, true}

Option end_position
end_position
-config=MC1.82,end_position={{POS,...}, END},...

Specify the end positions and if an exit node is required.

The configuration’s content is a list of the end positions and if a exit kind node is required at that position.

{POS,…}:

end position in the function body. Accepted members are:

  • compound: the end of the body when the body is a compound statement;

  • try: the end of the body when the body is a try block;

  • catch: the end of a catch handler when the body is a try block;

  • compound_try: the end of a try block when last statement of the function body is the try block;

  • compound_catch: the end of a catch handler when last statement of the function body is the handled try block;

END:

whether the exit position must always have an exit kind node. Accepted values are:

  • true: the exit position must always have an exit node;

  • false: the exit position does not have to have an exit node;

Default:

-config=MC1.82,end_position={{compound, try}, false}

Rule MC1.83

Summary

For functions with non-void return type:

  1. there shall be one return statement for every exit branch (including the end of the program),

  2. each return shall have an expression,

  3. return expression shall match the declared return type.

(See page 53 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Description

For this service, types match when

  • they have the same pointee depth and the innermost non-pointer types, without qualifiers, are compatible;

  • the conversion is a pointer decay;

  • the conversion is a null pointer to pointer.

Configuration

See generic service options.

Option statements
statements
-config=MC1.83,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.83,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=MC1.83,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option casts
casts
-config=MC1.83,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC1.84

Summary

For functions with void return type, return statements shall not have an expression. (See page 53 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.85

Summary

Functions called with no parameters should have empty parentheses. (See page 53 of MISRA-C-1998 [60] .)

Description

Note that the rule uses the semantic interpretation with respect to the phrase preceded by, as described in the MISRA forum thread “Rule 16.9”.

Configuration

See generic service options.

Option statements
statements
-config=MC1.85,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.85,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.86

Summary

If a function returns error information, then that error information should be tested. (See page 54 of MISRA-C-1998 [60] .)

Description

Calls to standard library functions whose return values contain error information are always checked.

To specify functions not in the standard library that return error information use the -call_properties global configuration with property error.

An error-returning function call is compliant if any of the following hold.

  • The returned value is tested directly and the result of the test is used.

  • The returned value is returned directly to the calling function which must have a similar error value expectation (that is, with the same error configuration).

  • The returned value is stored in a variable and that variable is tested in a statement that immediately follows the call in one of the following ways:

    • the test is in the condition part of an if statement;

    • the variable is in the condition expression of a switch statement, and the case and default labels select the specified error values;

    • it is a return statement that returns the result of the test.

Note that to specify the handling of a function’s error values use the handling service configuration.

Configuration

See generic service options.

Option calls
calls
-config=MC1.86,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option handling
handling
-config=MC1.86,handling={DECL_MATCHER, ID, SLCT, {{TAG, ACTION, FMT},...}},...

Specify the error handling.

The configuration’s content is an ordered list of a declaration matcher for the calling function, an error identifier and associated data about where the error is placed, where it should be tested and what actions should be taken.

Note that the first matching clause for the calling function and error identifier will be selected and the error value is checked using the associated data

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

ID:

an identifier declared in the -function_error global configuration.

SLCT:

specifies if handling is in a switch or if statement. Accepted values are:

  • any: any selection;

  • if: if statement;

  • switch: switch statement;

TAG:

a value tag declared in the -function_error global configuration.

ACTION:

action to be taken at end of related error branch. Accepted forms are:

  • any: the action is not checked

  • return_any(): the action is to return

  • return(RETURN_VAL): the action is to return RETURN_VAL

  • return_minus(RETURN_VAL): the action is to return the negated RETURN_VAL

  • return_call(CALL_MATCHER,RETURN_VAL): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression) where the RETURN_VAL is an argument to the call; the called function must have a noreturn attribute (see the -decl_properties global configuration)

  • goto(REGEX): the action is a goto statement with label matching REGEX

  • throw(TYPE_MATCHER): the action is a throw statement with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • call(CALL_MATCHER): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression)

  • switch(FUNCTION_ERROR): the action is a switch statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

  • if(FUNCTION_ERROR): the action is an if statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

REGEX

accepted forms are:

RETURN_VAL

accepted forms are:

  • return_value(): the returned value

  • INTEGER: the value

  • STMT_MATCHER: a sub-expression of an expression matching STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template callpost__default_fmt) to specify the message describing ACTION.

Default:

-config=MC1.86,handling={}

Rule MC1.87

Summary

#include statements in a file shall only be preceded by other pre- processor directives or comments. (See page 54 of MISRA-C-1998 [60] .)

Exceptions

The headers and the exception service configuration allow for some exceptions to this rule.

Configuration

See generic service options.

Option headers
headers
-config=MC1.87,headers={TAGS, HEADER_MATCHER},...

Specifies report tags for the #include directives.

The configuration’s content is a list of clauses specifying report tags for matching #include names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

HEADER_MATCHER:

the #include argument matcher including quotes or chevrons. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option exception
exception
-config=MC1.87,exception=EXCEPT,...

Specify allowed exceptions to this rule.

{EXCEPT,…}:

allowed exception to this rule. Accepted members are:

  • extern_C: constructs of the form extern "C" {...} are not considered to be code (for ‘C++’ rules);

  • extern_C_only: constructs of the form extern "C" are not considered to be code (for ‘C++’ rules); the following {…} may only contain preprocessor directives;

  • namespace_alias: constructs of the form namespace A = B are not considered to be code;

  • if_directive: directive subsections that are bounded by the #if, #else, #elif and #endif directives are considered as separate code chunks;


Rule MC1.88

Summary

Non-standard characters shall not occur in header file names in #include directives. (See page 54 of MISRA-C-1998 [60] .)

Description

To avoid the reporting of \ in file path names, the path_uses_backslash service configuration should be used.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MC1.88,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MC1.88,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MC1.89

Summary

The #include directive shall be followed by either a <filename> or "filename" sequence. (See page 55 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MC1.89,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MC1.89,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MC1.90

Summary

C macros shall only be used for symbolic constants, function-like macros, type qualifiers and storage class specifiers. (See page 55 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Description

Note that macros in header files that are used for include guards are compliant.

Configuration

See generic service options.

Option macros
macros
-config=MC1.90,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.91

Summary

Macros shall not be #define‘d and #undef‘d within a block. (See page 55 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option macros
macros
-config=MC1.91,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.92

Summary

#undef should not be used. (See page 55 of MISRA-C-1998 [60] .)

Description

Note that, for this service, the report category is the directive name undef.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MC1.92,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=MC1.92,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=MC1.92,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MC1.93

Summary

A function should be used in preference to a function-like macro. (See page 56 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Description

Note that a macro invocation is considered to be replaceable if all the following hold:

  • all of the the macro’s parameters occur in the macro body

  • the macro body’s text does not contain special tokens (e.g. __LINE__, __FILE__, __COUNTER_, #, ##);

  • the macro is not a system macro;

  • each of the macro invocation arguments is expanded to an expression that can be interpreted as an rvalue (and hence can be used as a function call argument);

  • the macro invocation is in a context that is supported by the standard for including function calls;

  • the macro is not used to emulate a template in C;

  • the macro does not expand a non-replaceable macro.

Imprecision

Cautions are reported when criteria have not been precisely determined.

Note that criteria such as the trade-off between code size and execution speed are not considered

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=MC1.93,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=MC1.93,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=MC1.93,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.94

Summary

A function-like macro shall not be “called” without all of its arguments. (See page 56 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.95

Summary

Arguments to a function-like macro shall not contain tokens that look like pre-processing directives. (See page 56 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option macros
macros
-config=MC1.95,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.96

Summary

In the definition of a function-like macro the whole definition, and each instance of a parameter, shall be enclosed in parentheses. (See page 56 of MISRA-C-1998 [60] .)

Exceptions

Exceptions to this are:

  • single tokens,

  • signed numeric constants,

  • statement-like code,

  • function-like calls,

  • array reference,

  • member operators,

  • and indirect calls to any of these.

Configuration

See generic service options.

Option macros
macros
-config=MC1.96,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.97

Summary

Identifiers in pre-processor directives should be defined before use. (See page 57 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Rule MC1.98

Summary

There shall be at most one occurrence of the # or ## pre-processor operators in a single macro definition. (See page 57 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option macros
macros
-config=MC1.98,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.99

Summary

All uses of the #pragma directive shall be documented and explained. (See page 57 of MISRA-C-1998 [60] .)

Description

Notes:

  • the STD.pragmdir behavior service configuration that has an associated -doc can be used to specify the documentation;

  • for each #pragma directive, the report will show a sample use with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.pragmdir

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC1.99,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC1.99,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC1.99,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC1.100

Summary

The defined pre-processor operator shall only be used in one of the two standard forms. (See page 57 of MISRA-C-1998 [60] .)

Description

The defined token must not be generated by macro expansion during the expansion of a #if or #elif directive.

Configuration

See generic service options.

Rule MC1.101

Summary

Pointer arithmetic should not be used. (See page 58 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Description

Note that an array index is not considered to be pointer arithmetic (see page 14 of MISRA-C:1998 TCD [61] ).

Exceptions

The array_arith_exception service configuration can be used to specify exceptions, such as allowing the increment/decrement operation on pointers.

Imprecision

Cautions are reported when the analyzer is uncertain whether the pointer points to an array.

Configuration

See generic service options.

Option array_arith_exception
array_arith_exception
-config=MC1.101,array_arith_exception=EXCEPT,...

Specify exceptions to the rule.

{EXCEPT,…}:

a set of pointer operations. Accepted members are:

  • array_index_reachable: array indexing when all objects reachable from the indexed expression are declared as arrays;

  • array_index_strict: array indexing when the indexed expression is not declared as an array;

  • array_index: array index;

  • add: + operation;

  • add_assign: += operation;

  • sub: - operation;

  • sub_assign: -= operation;

  • preinc: pre increment;

  • postinc: post increment;

  • predec: pre decrement;

  • postdec: post decrement;

  • incdec: any increment or decrement operation;

  • argument_passing: argument passing;

Default:

-config=MC1.101,array_arith_exception={}

Option declarations
declarations
-config=MC1.101,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.102

Summary

No more than 2 levels of pointer indirection should be used. (See page 58 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Description

More specifically, the rule reports if any of the following has more than 2 levels of pointer indirection:

  • the declared type of an object;

  • the return type of a function;

  • the type of a cast expression;

  • the type name argument to sizeof;

  • the type name argument in a compound literal expression;

  • an expression.

Configuration

See generic service options.

Rule MC1.103

Summary

Relational operators shall not be applied to pointer types except where both operands are of the same type and point to the same array, structure or union. (See page 58 of MISRA-C-1998 [60] .)

Imprecision

Cautions are reported when the checker is uncertain whether the pointers point to the same object.

Configuration

See generic service options.

Rule MC1.104

Summary

Non-constant pointers to functions shall not be used. (See page 58 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.104,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.105

Summary

All the functions pointed to by a single pointer to function shall be identical in the number and type of parameters and the return type. (See page 59 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option casts
casts
-config=MC1.105,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC1.106

Summary

The address of an object with automatic storage shall not be assigned to an object which may persist after the object has ceased to exist. (See page 59 of MISRA-C-1998 [60] .)

Imprecision

Cautions are reported when the address is possibly passed in a function call to another automatic object of larger scope or a static object.

Configuration

See generic service options.

Rule MC1.107

Summary

The null pointer shall not be de-referenced. (See page 59 of MISRA-C-1998 [60] , page 14 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Rule MC1.108

Summary

In the specification of a structure or union type, all members of the structure or union shall be fully specified. (See page 59 of MISRA-C-1998 [60] .)

Description

A pointer to an incomplete type is itself complete and is permitted, and therefore the use of opaque pointers is not reported.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.108,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.109

Summary

Overlapping variable storage shall not be used. (See page 59 of MISRA-C-1998 [60] .)

Description

Reports:

  • any use of a union (see normative text for MISRA Rule 109 on page 59 of MISRA-C:1998 [60] );

  • if an object is copied to another object that may have some overlap in memory using assignment;

  • if an object is copied (Undefined behavior 55 of the C90 standard [34]) using library functions.

Imprecision

False positives are reported because the checker needs to do a deeper (much more expensive) semantic analysis.

False negatives are present because the checker needs to do a deeper (much more expensive) semantic analysis.

Configuration

See generic service options.

Option types
types
-config=MC1.109,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MC1.109,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.110

Summary

Unions shall not be used to access the sub-parts of larger data types. (See page 60 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option types
types
-config=MC1.110,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MC1.110,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.111

Summary

Bit fields shall only be defined to be of type unsigned int or signed int. (See page 60 of MISRA-C-1998 [60] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.111,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC1.111,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC1.112

Summary

Bit fields of type signed int shall be at least 2 bits long. (See page 60 of MISRA-C-1998 [60] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.112,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC1.112,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC1.113

Summary

All the members of a structure (or union) shall be named and shall only be accessed via their name. (See page 60 of MISRA-C-1998 [60] , page 16 of MISRA-C-1998-TCD [61] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.113,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.114

Summary

Reserved words and standard library function names shall not be redefined or undefined. (See page 61 of MISRA-C-1998 [60] .)

Description

The reserved identifiers are defined to include all the following:

  • identifiers that are reserved by the C90 standard [34];

  • identifiers that are reserved by the standard used by the translation unit;

  • identifiers that are reserved for future library directions.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC1.114,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC1.114,reserved_standard="std()"

Option macros
macros
-config=MC1.114,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=MC1.114,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.115

Summary

Standard library function names shall not be reused. (See page 62 of MISRA-C-1998 [60] .)

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC1.115,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC1.115,reserved_standard="std()"

Option declarations
declarations
-config=MC1.115,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.116

Summary

All libraries used in production code shall be written to comply with the provisions of this document, and shall have been subject to appropriate validation. (See page 62 of MISRA-C-1998 [60] , page 16 of MISRA-C-1998-TCD [61] .)

Description

Hence, any library that is not analyzed by ECLAIR using the same enabled rules as the user code is reported.

Configuration

See generic service options.

Rule MC1.117

Summary

The validity of values passed to library functions shall be checked. (See page 62 of MISRA-C-1998 [60] , page 16 of MISRA-C-1998-TCD [61] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Implementation

Reports if specified arguments of calls to the standard library functions have not been validated.

An argument is taken to be validated if it is a constant expression or it is a variable and:

  • it occurs in an assertion prior to the function call in the context of a selection, iteration or block node;

  • the call is in a then or else branch of an if statement or the body of a while or for statement and the variable occurs in the condition part;

  • as in the previous case, but in a conditional operator expression.

Constant expressions are validated against the function’s requirements.

Imprecision

False negatives are present because not all functions’ requirements are checked.

Configuration

See generic service options.

Rule MC1.118

Summary

Dynamic heap memory allocation shall not be used. (See page 63 of MISRA-C-1998 [60] , page 16 of MISRA-C-1998-TCD [61] .)

Description

The black-list of functions to report is determined by the -decl_properties global configuration (to specify if a function is known to have the malloc property).

With the default values:

  • the use of any function with the malloc attribute will be reported;

  • The use of the standard library functions malloc, calloc, realloc, free, strdup, and operators new and delete will be reported.

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=MC1.118,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=MC1.118,extra_statements={}

Option statements
statements
-config=MC1.118,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC1.118,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC1.119

Summary

The error indicator errno shall not be used. (See page 63 of MISRA-C-1998 [60] .)

Description

Hence, there must be no use of the macro errno defined in errno.h no use of the function perrno() declared in stdio.h.

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC1.119,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC1.119,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.120

Summary

The macro offsetof, in library <stddef.h>, shall not be used. (See page 64 of MISRA-C-1998 [60] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.120,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC1.120,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.121

Summary

<locale.h> and the setlocale function shall not be used. (See page 64 of MISRA-C-1998 [60] , page 16 of MISRA-C-1998-TCD [61] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.121,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.122

Summary

The setjmp macro and the longjmp function shall not be used. (See page 64 of MISRA-C-1998 [60] .)

Description

Hence, there must be no use of the macro setjmp defined in setjmp.h and the function longjmp declared in setjmp.h.

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.122,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC1.122,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.123

Summary

The signal handling facilities of <signal.h> shall not be used. (See page 64 of MISRA-C-1998 [60] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.123,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC1.123,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.124

Summary

The input/output library <stdio.h> shall not be used in production code. (See page 64 of MISRA-C-1998 [60] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.124,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC1.124,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC1.125

Summary

The library functions atof, atoi and atol from library <stdlib.h> shall not be used. (See page 64 of MISRA-C-1998 [60] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.125,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.126

Summary

The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used. (See page 64 of MISRA-C-1998 [60] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC1.126,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC1.126,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC1.127

Summary

The time handling functions of library <time.h> shall not be used. (See page 65 of MISRA-C-1998 [60] , page 16 of MISRA-C-1998-TCD [61] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC1.127,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC1.127,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


MISRA-C:1998 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA-C:1998 coding standard [60], taking into account the technical clarifications [61].

For all guidelines, the mapping between the MISRA-C:1998 rules and the ECLAIR service identifiers is one-to-one and straightforward. e.g., MISRA-C:1998 Rule 1 maps to ECLAIR service MC1.1.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC1 synopsis: supported MISRA-C:1998 rules

Id

Headline

Precision

MC1.1

All code shall conform to ISO 9899 standard C, with no extensions permitted

Best-effort

MC1.2

Code written in languages other than C should only be used if there is a defined interface standard for object code to which the compilers/assemblers for both languages conform

Process

MC1.3

Assembly language functions that are called from C should be written as C functions containing only in-line assembly language, and in-line assembly language should not be embedded in normal C code

Exact

MC1.4

Provision should be made for appropriate run-time checking

Process

MC1.5

Only those characters and escape sequences which are defined in the ISO C standard shall be used

Exact

MC1.6

Values of character types shall be restricted to a defined and documented subset of ISO 10646-1

Process

MC1.7

Trigraphs shall not be used

Exact

MC1.8

Multibyte characters and wide string literals shall not be used

Exact

MC1.9

Comments shall not be nested

Exact

MC1.10

Sections of code should not be “commented out”

Heuristic

MC1.11

Identifiers (internal and external) shall not rely on significance of more than 31 characters. Furthermore the compiler/linker shall be checked to ensure that 31 character significance and case sensitivity are supported for external identifiers

Exact

MC1.12

No identifier in one name space shall have the same spelling as an identifier in another name space

Exact

MC1.13

The basic types of char, int, short, long, float and double should not be used, but specific-length equivalents should be typedef‘d for the specific compiler, and these type names used in the code

Exact

MC1.14

The type char shall always be declared as unsigned char or signed char

Exact

MC1.15

Floating point implementations should comply with a defined floating point standard

Process

MC1.16

The underlying bit representations of floating point numbers shall not be used in any way by the programmer

Complete

MC1.17

typedef names shall not be reused

Exact

MC1.18

Numeric constants should be suffixed to indicate type, where an appropriate suffix is available

Exact

MC1.19

Octal constants (other than zero) shall not be used

Exact

MC1.20

All object and function identifiers shall be declared before use

Exact

MC1.21

Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier

Exact

MC1.22

Declarations of objects should be at function scope unless a wider scope is necessary

Exact

MC1.23

All declarations at file scope should be static where possible

Exact

MC1.24

Identifiers shall not simultaneously have both internal and external linkage in the same translation unit

Exact

MC1.25

An identifier with external linkage shall have exactly one external definition

Exact

MC1.26

If objects or functions are declared more than once they shall have compatible declarations

Exact

MC1.27

External objects should not be declared in more than one file

Exact

MC1.28

The register storage class specifier should not be used

Exact

MC1.29

The use of a tag shall agree with its declaration

Exact

MC1.30

All automatic variables shall have been assigned a value before being used

Complete

MC1.31

Braces shall be used to indicate and match the structure in the non-zero initialisation of arrays and structures

Exact

MC1.32

In an enumerator list, the = construct shall not be used to explicitly initialise members other than the first, unless all items are explicitly initialised

Exact

MC1.33

The right hand operand of a && or || operator shall not contain side effects

Safe

MC1.34

The operands of a logical && or || shall be primary expressions

Exact

MC1.35

Assignment operators shall not be used in expressions which return Boolean values

Exact

MC1.36

Logical operators should not be confused with bitwise operators

Exact

MC1.37

Bitwise operations shall not be performed on signed integer types

Exact

MC1.38

The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the left hand operand (inclusive)

Complete

MC1.39

The unary minus operator shall not be applied to an unsigned expression

Exact

MC1.40

The sizeof operator should not be used on expressions that contain side effects

Exact

MC1.41

The implementation of integer division in the chosen compiler should be determined, documented and taken into account

Process

MC1.42

The comma operator shall not be used, except in the control expression of a for loop

Exact

MC1.43

Implicit conversions which may result in a loss of information shall not be used

Exact

MC1.44

Redundant explicit casts should not be used

Exact

MC1.45

Type casting from any type to or from pointers shall not be used

Exact

MC1.46

The value of an expression shall be the same under any order of evaluation that the standard permits

Safe

MC1.47

No dependence should be placed on C’s operator precedence rules in expressions

Exact

MC1.48

Mixed precision arithmetic should use explicit casting to generate the desired result

Exact

MC1.49

Tests of a value against zero should be made explicit, unless the operand is effectively Boolean

Exact

MC1.50

Floating point variables shall not be tested for exact equality or inequality

Best-effort

MC1.51

Evaluation of constant unsigned integer expressions should not lead to wrap-around

Exact

MC1.52

There shall be no unreachable code

Best-effort

MC1.53

All non-null statements shall have a side-effect

Complete

MC1.54

A null statement shall only occur on a line by itself, and shall not have any other text on the same line

Exact

MC1.55

Labels should not be used, except in switch statements

Exact

MC1.56

The goto statement shall not be used

Exact

MC1.57

The continue statement shall not be used

Exact

MC1.58

The break statement shall not be used (except to terminate the cases of a switch statement)

Exact

MC1.59

The statements forming the body of an if, else if, else, while, do ... while or for statement shall always be enclosed in braces

Exact

MC1.60

All if, else if constructs should contain a final else clause

Exact

MC1.61

Every non-empty case clause in a switch statement shall be terminated with a break statement

Exact

MC1.62

All switch statements should contain a final default clause

Exact

MC1.63

A switch expression should not represent a Boolean value

Exact

MC1.64

Every switch statement shall have at least one case

Exact

MC1.65

Floating point variables shall not be used as loop counters

Exact

MC1.66

Only expressions concerned with loop control should appear within a for statement

Complete

MC1.67

Numeric variables being used within a for loop for iteration counting should not be modified in the body of the loop

Complete

MC1.68

Functions shall always be declared at file scope

Exact

MC1.69

Functions with variable numbers of arguments shall not be used

Exact

MC1.70

Functions shall not call themselves, either directly or indirectly

Complete

MC1.71

Functions shall always have prototype declarations and the prototype shall be visible at both the function definition and call

Exact

MC1.72

For each function parameter the type given in the declaration and definition shall be identical, and the return types shall also be identical

Exact

MC1.73

Identifiers shall either be given for all of the parameters in a function prototype declaration, or for none

Exact

MC1.74

If identifiers are given for any of the parameters, then the identifiers used in the declaration and definition shall be identical

Exact

MC1.75

Every function shall have an explicit return type

Exact

MC1.76

Functions with no parameters shall be declared with parameter type void

Exact

MC1.77

The unqualified type of parameters passed to a function shall be compatible with the unqualified expected types defined in the function prototype

Exact

MC1.78

The number of parameters passed to a function shall match the function prototype

Exact

MC1.79

The values returned by void functions shall not be used

Exact

MC1.80

Void expressions shall not be passed as function parameters

Exact

MC1.81

const qualification should be used on function parameters which are passed by reference, where it is intended that the function will not modify the parameter

Exact

MC1.82

A function should have a single point of exit

Exact

MC1.83

For functions with non-void return type:

  1. there shall be one return statement for every exit branch (including the end of the program),

  2. each return shall have an expression,

  3. return expression shall match the declared return type.

Exact

MC1.84

For functions with void return type, return statements shall not have an expression

Exact

MC1.85

Functions called with no parameters should have empty parentheses

Exact

MC1.86

If a function returns error information, then that error information should be tested

Process

MC1.87

#include statements in a file shall only be preceded by other pre- processor directives or comments

Exact

MC1.88

Non-standard characters shall not occur in header file names in #include directives

Exact

MC1.89

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC1.90

C macros shall only be used for symbolic constants, function-like macros, type qualifiers and storage class specifiers

Exact

MC1.91

Macros shall not be #define‘d and #undef‘d within a block

Exact

MC1.92

#undef should not be used

Exact

MC1.93

A function should be used in preference to a function-like macro

Complete

MC1.94

A function-like macro shall not be “called” without all of its arguments

Exact

MC1.95

Arguments to a function-like macro shall not contain tokens that look like pre-processing directives

Exact

MC1.96

In the definition of a function-like macro the whole definition, and each instance of a parameter, shall be enclosed in parentheses

Exact

MC1.97

Identifiers in pre-processor directives should be defined before use

Exact

MC1.98

There shall be at most one occurrence of the # or ## pre-processor operators in a single macro definition

Exact

MC1.99

All uses of the #pragma directive shall be documented and explained

Process

MC1.100

The defined pre-processor operator shall only be used in one of the two standard forms

Exact

MC1.101

Pointer arithmetic should not be used

Complete

MC1.102

No more than 2 levels of pointer indirection should be used

Exact

MC1.103

Relational operators shall not be applied to pointer types except where both operands are of the same type and point to the same array, structure or union

Complete

MC1.104

Non-constant pointers to functions shall not be used

Exact

MC1.105

All the functions pointed to by a single pointer to function shall be identical in the number and type of parameters and the return type

Exact

MC1.106

The address of an object with automatic storage shall not be assigned to an object which may persist after the object has ceased to exist

Safe

MC1.107

The null pointer shall not be de-referenced

Exact

MC1.108

In the specification of a structure or union type, all members of the structure or union shall be fully specified

Exact

MC1.109

Overlapping variable storage shall not be used

Best-effort

MC1.110

Unions shall not be used to access the sub-parts of larger data types

Exact

MC1.111

Bit fields shall only be defined to be of type unsigned int or signed int

Exact

MC1.112

Bit fields of type signed int shall be at least 2 bits long

Exact

MC1.113

All the members of a structure (or union) shall be named and shall only be accessed via their name

Exact

MC1.114

Reserved words and standard library function names shall not be redefined or undefined

Exact

MC1.115

Standard library function names shall not be reused

Exact

MC1.116

All libraries used in production code shall be written to comply with the provisions of this document, and shall have been subject to appropriate validation

Exact

MC1.117

The validity of values passed to library functions shall be checked

Best-effort

MC1.118

Dynamic heap memory allocation shall not be used

Exact

MC1.119

The error indicator errno shall not be used

Exact

MC1.120

The macro offsetof, in library <stddef.h>, shall not be used

Exact

MC1.121

<locale.h> and the setlocale function shall not be used

Exact

MC1.122

The setjmp macro and the longjmp function shall not be used

Exact

MC1.123

The signal handling facilities of <signal.h> shall not be used

Exact

MC1.124

The input/output library <stdio.h> shall not be used in production code

Exact

MC1.125

The library functions atof, atoi and atol from library <stdlib.h> shall not be used

Exact

MC1.126

The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used

Exact

MC1.127

The time handling functions of library <time.h> shall not be used

Exact

The MISRA C:2004 Coding Rules

For the MISRA-C:2004 [62] coding rules, the exact definition takes into account all clarifications published in [63] and in the MISRA information and discussion forum. Note that for each of the supported MISRA-C:2004 rules, the identifier for the corresponding ECLAIR service is obtained by adding the prefix MC2., thereby obtaining, for example: MC2.1.1, MC2.3.4, MC2.10.1, …

Note that the page numbers included in the references to [62] in the ECLAIR service summaries are for the PDF version of [62] .

Rule MC2.1.1

Summary

All code shall conform to ISO 9899:1990 “Programming languages - C”, amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2:1996. (See page 29 of MISRA-C-2004 [62] , page 9 of MISRA-C-2004-Permits-1 [65] .)

Description

Notes:

  • Code that is ill-formed is always reported.

  • Code that has undefined or unspecified behavior is reported as an extension to the standard if the behavior configuration of the related ancillary services is specified.

  • Except as stated below, any breaching of the implementation’s limits is reported.

  • The normative text for MISRA Rule 1.1 on page 29 of MISRA-C:2004 [62] notes that the limits on the significant number of initial characters in an identifier are checked by MISRA Rule 5.1 so that exceeding these should not be reported by MISRA Rule 1.1.

Imprecision

Cautions are reported when the behavior cannot be determined.

When the undefined or unspecified behavior item is undecidable, the related ancillary service reports possible non-compliance as a caution.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfldtp STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.charxwde STD.cissnest STD.cmntstle STD.cmpdltrl STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.extident STD.flexaray STD.forhdecl STD.freestlb STD.funojptr STD.iddiflkg STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.prepdirc STD.pteincmp STD.ptrnconv STD.ptypnest STD.qotemtch STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC2.1.2

Summary

No reliance shall be placed on undefined or unspecified behaviour. (See page 29 of MISRA-C-2004 [62] .)

Description

Note that only those issues that are not specifically addressed by other MISRA rules are addressed by MISRA Rule 1.2.

Imprecision

False positives are reported due to the reporting of any use of the qsort and bsearch functions declared in stdlib.h.

Note that the Annex G.1 of the C90 standard [34] states that “The order in an array sorted by the qsort function of two members that compare as equal” and “Which of two members that compare as equal is returned by the bsearch function” are unspecified. Thus, any use of these functions that does not depend on these issues will have false positives.

False negatives are present due to incomplete semantic information.

This service depends upon the configuration of the following ancillary services: STD.anonstct STD.arthinvl STD.bsercheq STD.charescp STD.charset STD.charxwde STD.defined STD.encderor STD.eofnl STD.fntpqual STD.fprscarg STD.fprscfmt STD.hostmain STD.iddiflkg STD.intnlobj STD.ipconrep STD.linedir STD.mainrtrn STD.negshift STD.ptrnconv STD.qotemtch STD.qsortord STD.stdcctxt STD.stdcprag STD.strlitrl STD.vaargast

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.1.2,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC2.1.3

Summary

Multiple compilers and/or languages shall only be used if there is a common defined interface standard for object code to which the languages/compilers/assemblers conform. (See page 29 of MISRA-C-2004 [62] .)

Description

Compilers can be white-listed using the compilers service configuration.

For example, with the configuration lines:

-tool_tag={any_g,"language(c)&&tool(^gcc[^/]*$) || language(c++)&&tool(^g\\+\\+[^/]*$)"}
-config=MC2.1.3,compilers=any_g

all gcc and g++ compilers are taken to be compatible.

Implementation

Reports if more than one compiler that is not white-listed is used to compile and link the program.

Configuration

See generic service options.

Option compilers
compilers
-config=MC2.1.3,compilers=TOOL_MATCHER,...

Specify the tool tags; compilers are taken to be compatible if and only if they have the same tag.

The configuration’s content is a list of tags matching compatible compilers.

TOOL_MATCHER:

a -tool_tag identifier or a matcher expression whose matching compilers are all considered as compatible.


Rule MC2.1.4

Summary

The compiler/linker shall be checked to ensure that 31 character significance and case sensitivity are supported for external identifiers. (See page 30 of MISRA-C-2004 [62] .)

Description

The case sensitivity and number of significant initial characters supported by the implementation in an external identifiers can be specified with the STD.extidsig behavior service configuration.

This service depends upon the configuration of the following ancillary services: STD.extidsig

Configuration

See generic service options.

Rule MC2.1.5

Summary

Floating-point implementations should comply with a defined floating-point standard. (See page 30 of MISRA-C-2004 [62] .)

Description

The STD.floatstd behavior service configuration can be used to specify the documentation.

The default number of reported samples for use of floating point types is 1, but this can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.floatstd

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.1.5,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC2.1.5,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC2.1.5,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC2.2.1

Summary

Assembly language shall be encapsulated and isolated. (See page 30 of MISRA-C-2004 [62] .)

Description

A function is non-compliant if it contains an unencapsulated asm statement and a non-asm statement Notes:

  • Expressions and statements specified using the configuration parameters ignored_stmts service configurations are said to be ignored.

  • A macro that contains, other than ignored code, only asm statements is considered a valid asm encapsulator.

  • A function that contains, other than ignored code, only asm statements, possibly expanded from asm encapsulator macros, or calls to asm encapsulator functions is considered a valid asm encapsulator.

  • Any asm statements that are expanded from a macro or in a macro-defined do-while-zero loop idiom are ignored.

Configuration

See generic service options.

Option ignored_stmts
ignored_stmts
-config=MC2.2.1,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MC2.2.2

Summary

Source code shall only use /* ... */ style comments. (See page 30 of MISRA-C-2004 [62] .)

Description

That is, the rule reports all BCPL-style comments that begin with // and continue to the end of line.

Configuration

See generic service options.

Option comments
comments
-config=MC2.2.2,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC2.2.3

Summary

The character sequence /* shall not be used within a comment. (See page 31 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option comments
comments
-config=MC2.2.3,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=MC2.2.3,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC2.2.4

Summary

Sections of code should not be “commented out”. (See page 31 of MISRA-C-2004 [62] .)

Description

Any non-compiled sources are reported as additional information.

Note that, by default, doxygen comments are ignored; this can be changed using the ignored_comments service configuration. For example, with the following configure line, all comments will be checked:

-doc="Avoid ignoring doxygen comments."
-config=MC2.2.4,+ignored_comments="none()"

Implementation

A comment is non-compliant if it looks like code. That is, a comment is reported if a statistical measure (based on the total number of tokens and number of keywords and operators) is exceeded.

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

It is not possible to precisely differentiate code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

/* This is a comment */

Configuration

See generic service options.

Option comments
comments
-config=MC2.2.4,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=MC2.2.4,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=MC2.2.4,code_lines=0

Option ignored_comments
ignored_comments
-config=MC2.2.4,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC2.2.4,ignored_comments=__doxygen_comments

Rule MC2.3.1

Summary

All usage of implementation-defined behaviour shall be documented. (See page 31 of MISRA-C-2004 [62] .)

Description

Notes:

  • The behavior configuration of the related ancillary services that has an associated -doc can be used to specify the behavior and documentation.

  • For each implementation-defined item, language and compiler, the project report will show a set of samples of code that have possibly implementation-defined behavior and a summary message.

  • The behavior_sampling service configuration can be used to specify the maximum number of samples of code to be reported for each item checked; the default value is 1.

Imprecision

False positives are reported because whether code can have implementation-defined behavior is undecidable.

If there is no documentation for an implementation-defined behavior item, then code will be reported as non-compliant if the checker cannot guarantee that the code will not lead to this behavior.

This service depends upon the configuration of the following ancillary services: STD.asrtterm STD.bytebits STD.caselimt STD.charmult STD.charppif STD.datetime STD.decllimt STD.diagidnt STD.enumtype STD.floatnrw STD.freesten STD.freestlb STD.freestnd STD.inclexpd STD.inclfile STD.intfloat STD.mainargv STD.nullpntr STD.objbytes STD.register STD.strerror STD.volatltp

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.3.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC2.3.1,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC2.3.1,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC2.3.2

Summary

The character set and the corresponding encoding shall be documented. (See page 31 of MISRA-C-2004 [62] , page 10 of MISRA-C-2004-TC1 [63] .)

Description

Notes:

Imprecision

Cautions are reported when the behavior cannot be determined and the related ancillary service reports possible non-compliance as a caution.

This service depends upon the configuration of the following ancillary services: STD.charsmap STD.charsmem STD.charsval

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.3.2,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC2.3.2,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC2.3.2,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC2.3.3

Summary

The implementation of integer division in the chosen compiler should be determined, documented and taken into account. (See page 32 of MISRA-C-2004 [62] .)

Description

Notes:

  • the STD.divrmsgn behavior service configuration can be used to specify the expected direction of rounding when dividing two signed integers;

  • the report will show a sample use of integer division with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.divrmsgn

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.3.3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC2.3.3,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC2.3.3,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC2.3.4

Summary

All uses of the #pragma directive shall be documented and explained. (See page 32 of MISRA-C-2004 [62] .)

Description

Notes:

  • the STD.pragmdir behavior service configuration that has an associated -doc can be used to specify the documentation;

  • for each #pragma directive, the report will show a sample use with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.pragmdir

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.3.4,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC2.3.4,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC2.3.4,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC2.3.5

Summary

If it is being relied upon, the implementation-defined behaviour and packing of bitfields shall be documented. (See page 32 of MISRA-C-2004 [62] .)

Description

Notes:

  • the normative text for this rule on page 35 of MISRA-C:2004 [62] adds that the packing together of short-length data to economise on storage is the only acceptable use of bit-fields and recommends that structures be declared specifically to hold the sets of bit-fields, and do not include any other data within the same structure;

  • the STD.bitfldor behavior service configuration can be used to specify the documentation;

  • the report will show a sample of expressions that have class, struct or union types that contain bit-fields; the number of samples can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.bitfldor

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.3.5,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MC2.3.5,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MC2.3.5,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MC2.3.6

Summary

All libraries used in production code shall be written to comply with the provisions of this document, and shall have been subject to appropriate validation. (See page 33 of MISRA-C-2004 [62] .)

Description

All libraries that are not analyzed by ECLAIR using the same enabled rules as the user code are reported.

Configuration

See generic service options.

Rule MC2.4.1

Summary

Only those escape sequences that are defined in the ISO C standard shall be used. (See page 33 of MISRA-C-2004 [62] , page 10 of MISRA-C-2004-TC1 [63] .)

Description

Note that page 10 of MISRA-C:2004 TC1 [63] clarifies:

  • that only the simple escape sequences: a, b, f, n, r, t, v, ', ", ?, \, 0 are compliant;

  • and that use of any hexadecimal or octal escape sequences other than \0 is non-compliant.

Configuration

See generic service options.

Rule MC2.4.2

Summary

Trigraphs shall not be used. (See page 33 of MISRA-C-2004 [62] .)

Description

Note that trigraphs are denoted by one of the sequences ??=, ??(, ??<, ??/, ??), ??>, ??', ??|, and ??-.

Configuration

See generic service options.

Rule MC2.5.1

Summary

Identifiers (internal and external) shall not rely on the significance of more than 31 characters. (See page 34 of MISRA-C-2004 [62] , page 10 of MISRA-C-2004-TC1 [63] , page 14 of MISRA-C-2004-Permits-1 [65] .)

Description

Notes:

  • This applies across all namespaces (see page 10 of MISRA-C:2004 TC1 [63] ).

  • The number of significant initial characters supported by the implementation in an external identifiers can be changed with the STD.extidsig behavior service configuration.

  • The number of significant initial characters supported by the implementation in non-external identifiers (internal identifiers, macro names and macro parameter names) can be changed with the option STD.nexidsig behavior.

This service depends upon the configuration of the following ancillary services: STD.extidsig STD.nexidsig

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MC2.5.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MC2.5.1,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.5.2

Summary

Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier. (See page 34 of MISRA-C-2004 [62] .)

Description

Note that the normative text for this rule on page 34 of MISRA-C:2004 [62] clarifies what is meant by scope here: identifiers that have file scope are considered as having the outermost scope. Identifiers that have block scope have a more inner scope. Successive, nested blocks, introduce more inner scopes.

Configuration

See generic service options.

Rule MC2.5.3

Summary

A typedef name shall be a unique identifier. (See page 34 of MISRA-C-2004 [62] , page 11 of MISRA-C-2004-TC1 [63] .)

Description

This rule does not report when:

  • the other entity is a typedef or;

  • both typedefs have the same declaration in the same header file, and the file is included in multiple source files.

Note also that the typedef name must not be used for any macro or macro parameter.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MC2.5.3,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC2.5.3,reuse_by_location=address

Rule MC2.5.4

Summary

A tag name shall be a unique identifier. (See page 35 of MISRA-C-2004 [62] , page 11 of MISRA-C-2004-TC1 [63] .)

Description

The rule does not report when:

  • the other entity is a tag name or;

  • both the tag names have the same declaration in the same header file, and the file is included in multiple source files.

Note also that the tag name must not be used for any macro or macro parameter.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MC2.5.4,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC2.5.4,reuse_by_location=address

Rule MC2.5.5

Summary

No object or function identifier with static storage duration should be reused. (See page 35 of MISRA-C-2004 [62] .)

Description

Notes:

  • the rule applies to any variable or function:

    • with external linkage or,

    • has the static storage class specifier or,

    • is not externally visible;

  • identifiers coming from the same spelling location are not considered a reuse;

  • if the declaration is in a macro definition, then each use of the macro is regarded as a distinct use of the identifier;

  • see the MISRA forum thread “Rule 5.5 and local static variables”.

Note also that the variable or function name must not be used for any macro or macro parameter.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MC2.5.5,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC2.5.5,reuse_by_location=address

Rule MC2.5.6

Summary

No identifier in one name space should have the same spelling as an identifier in another name space, with the exception of structure member and union member names. (See page 36 of MISRA-C-2004 [62] , page 11 of MISRA-C-2004-TC1 [63] .)

Description

The summarize_max service configuration provides an alternative so that, instead of marking all instances of an identifier’s reuse, the rule reports a specified number of such instances as well as the total number of times the name of the identifier is used.

Configuration

See generic service options.

Option summarize_max
summarize_max
-config=MC2.5.6,summarize_max=MAX

Specify the maximum number of clashes to be shown.

MAX:

if Max = -1 or the number of clashes for an identifier is less than or equal to Max, then all the clashes are shown. Otherwise only Max clashes are shown and a program summary will show the total number of clashes for that identifier. It must be an integer greater than or equal to -1.

Default:

-config=MC2.5.6,summarize_max=0

Option reuse_by_location
reuse_by_location
-config=MC2.5.6,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC2.5.6,reuse_by_location=address

Rule MC2.5.7

Summary

No identifier name should be reused. (See page 36 of MISRA-C-2004 [62] .)

Description

Notes:

  • Macros and their arguments are also checked - see the MISRA forum thread “Identifier used as variable and function-like macro”.

  • The summarize_max service configuration provides an alternative so that, instead of marking all instances of an identifier’s reuse, the rule reports a specified number of such instances as well as the total number of times the name of the identifier is used.

  • if the declaration is in a macro definition, then each use of the macro will be regarded as a distinct use of the identifier.

Configuration

See generic service options.

Option summarize_max
summarize_max
-config=MC2.5.7,summarize_max=MAX

Specify the maximum number of clashes to be shown.

MAX:

if Max = -1 or the number of clashes for an identifier is less than or equal to Max, then all the clashes are shown. Otherwise only Max clashes are shown and a program summary will show the total number of clashes for that identifier. It must be an integer greater than or equal to -1.

Default:

-config=MC2.5.7,summarize_max=0

Option reuse_by_location
reuse_by_location
-config=MC2.5.7,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MC2.5.7,reuse_by_location=address

Rule MC2.6.1

Summary

The plain char type shall be used only for the storage and use of character values. (See page 37 of MISRA-C-2004 [62] , page 12 of MISRA-C-2004-TC1 [63] .)

Description

An object of plain char type must be one of the following:

  • an operand of the binary operators =, == or !=,

  • an operand of an explicit cast to an integral type,

  • the second or third operand of the conditional operator ?: (see page 12 of MISRA-C:2004 TC1 [63] ).

Note that explicit casts are permitted (see the MISRA forum thread “6.1, 6.2 and casts?”).

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.6.1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.6.2

Summary

signed and unsigned char type shall be used only for the storage and use of numeric values. (See page 37 of MISRA-C-2004 [62] , page 12 of MISRA-C-2004-TC1 [63] .)

Description

Note that explicit casts to non-numeric values are permitted (see the MISRA forum thread “6.1, 6.2 and casts?”)

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.6.2,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.6.3

Summary

typedefs that indicate size and signedness should be used in place of the basic numerical types. (See page 37 of MISRA-C-2004 [62] , page 12 of MISRA-C-2004-TC1 [63] .)

Description

The rule assumes the proposal for the typedef names in the normative text for MISRA Rule 6.3 on page 37 of MISRA-C:2004 [62] as the default schema; hence the typedef name is non-compliant if it does not have one of the following forms (where @BITS@ is replaced by the length in bits):

  • signed integer type - int@BITS@_t,

  • unsigned integer type - uint@BITS@_t,

  • floating type - float@BITS@_t.

The naming service configuration can be used to change the schema.

Configuration

See generic service options.

Option naming
naming
-config=MC2.6.3,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MC2.6.3,naming=misra

Option declarations
declarations
-config=MC2.6.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC2.6.3,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC2.6.4

Summary

Bit fields shall only be defined to be of type unsigned int or signed int. (See page 38 of MISRA-C-2004 [62] , page 15 of MISRA-C-2004-Permits-1 [65] .)

Description

Note that, for this service, the report category is the reported type.

This service depends upon the configuration of the following ancillary services: STD.bitfldtp

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.6.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC2.6.4,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option behaviors
behaviors
-config=MC2.6.4,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC2.6.5

Summary

Bit fields of signed type shall be at least 2 bits long. (See page 38 of MISRA-C-2004 [62] , page 13 of MISRA-C-2004-TC1 [63] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.6.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC2.6.5,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC2.7.1

Summary

Octal constants (other than zero) and octal escape sequences shall not be used. (See page 38 of MISRA-C-2004 [62] , page 13 of MISRA-C-2004-TC1 [63] .)

Exceptions

The integer constant 0 and the octal escape sequence \0 are allowed.

Configuration

See generic service options.

Option literals
literals
-config=MC2.7.1,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MC2.8.1

Summary

Functions shall have prototype declarations and the prototype shall be visible at both the function definition and call. (See page 39 of MISRA-C-2004 [62] .)

Description

Reports:

  • a function declaration or definition that does not have a function prototype;

  • a reference to a function before a prototype declaration or definition of the function;

  • a function with external linkage defined in the compilation main file that does not have a previous prototype declaration that is located in a header file;

  • a function with internal linkage defined in the compilation main file that does not have a previous prototype declaration.

The last item follows from the forum clarification where MISRA explicitly states that internal linkage functions should have a previous prototype; see the MISRA forum thread “Rule 8.1 and static functions”.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.2

Summary

Whenever an object or function is declared or defined, its type shall be explicitly stated. (See page 39 of MISRA-C-2004 [62] .)

Description

Notes:

  • the type of any parameter or variable declaration must be explicitly stated;

  • the type of the return value of any function declaration or definition must be explicitly stated;

  • the type of any typedef declaration must be explicitly stated.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.3

Summary

For each function parameter the type given in the declaration and definition shall be identical, and the return types shall also be identical. (See page 39 of MISRA-C-2004 [62] .)

Description

Note that function definitions without a prototype declaration are not checked.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.4

Summary

If objects or functions are declared more than once their types shall be compatible. (See page 39 of MISRA-C-2004 [62] .)

Description

Notes:

  • if a variable is declared more than once, the types must be compatible;

  • if a function has more than one prototype declaration or definition, the corresponding parameter types or return types must be compatible.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.5

Summary

There shall be no definitions of objects or functions in a header file. (See page 40 of MISRA-C-2004 [62] , page 14 of MISRA-C-2004-TC1 [63] , page 16 of MISRA-C-2004-Permits-1 [65] .)

Description

Note that a header file is any file that is included via the #include directive, regardless of name or suffix (see page 14 of MISRA-C:2004 TC1 [63] ).

Exceptions

The following definitions are allowed:

  • non-inline, non-repeatable function definitions,

  • const objects with internal linkage.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.6

Summary

Functions shall be declared at file scope. (See page 40 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.7

Summary

Objects shall be defined at block scope if they are only accessed from within a single function. (See page 40 of MISRA-C-2004 [62] , page 14 of MISRA-C-2004-TC1 [63] .)

Description

This rule reports a variable if all the following hold:

  • the variable has linkage;

  • the variable is referenced;

  • all references to it are in the same function;

  • the declaration is not in a public API file.

  • if it is a variable with external linkage, then all references are in the same unit.

A file can be declared part of a public API by:

  • exploiting the globally defined decl_selector __public_api_decls;

  • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

variables declared in files whose names match the regular expression ^my_public_header.h$ will not be reported.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.8

Summary

An external object or function shall be declared in one and only one file. (See page 40 of MISRA-C-2004 [62] .)

Description

Note that if the default value for config option decl_option is changed (from decl_once) to decl, then this rule will report only if the declaration is in a more than one file (see comment for Rule 8.5 on page 14 of MISRA-C:2004 TC1 [63] ).

Configuration

See generic service options.

Option decl_option
decl_option
-config=MC2.8.8,decl_option=OPT

Specify the checks to be made.

OPT:

tags indicating what should be checked. Accepted values are:

  • decl_once: it is reported if an external variable or function is not declared exactly once;

  • decl: it is reported if an external variable or function is declared in more than one file;

  • defn: it is reported if an external variable or function is defined in more than one file;

  • decl_included: it is reported if an external variable or function is declared in more than one header file or if it is declared in the main (i.e., not an included) file;

  • var_decl_only_included: it is reported if external variables are not declared in a single included file;

Default:

-config=MC2.8.8,decl_option=decl_once

Option declarations
declarations
-config=MC2.8.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.9

Summary

An identifier with external linkage shall have exactly one external definition. (See page 40 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.10

Summary

All declarations and definitions of objects or functions at file scope shall have internal linkage unless external linkage is required. (See page 41 of MISRA-C-2004 [62] .)

Description

A variable or function is reported if:

  • it has external linkage;

  • it is referenced; and

  • the declaration or definition is not in a public API file.

  • all references to it are in the same unit.

A file can be declared part of a public API by:

  • exploiting the globally defined decl_selector __public_api_decls;

  • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

variables declared in files whose names match the regular expression ^my_public_header.h$ will not be reported.

Configuration

See generic service options.

Option definition_in_same_unit
definition_in_same_unit
-config=MC2.8.10,definition_in_same_unit=BOOL

Specify if the definition must be in the same translation unit as the references.

BOOL

Accepted values are:

  • true: the definition must be in the same translation unit as the references;

  • false: the definition does not have to be in the same translation unit as the references;

Default:

-config=MC2.8.10,definition_in_same_unit=true

Option declarations
declarations
-config=MC2.8.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.11

Summary

The static storage class specifier shall be used in definitions and declarations of objects and functions that have internal linkage. (See page 41 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.8.12

Summary

When an array is declared with external linkage, its size shall be stated explicitly or defined implicitly by initialisation. (See page 41 of MISRA-C-2004 [62] , page 14 of MISRA-C-2004-TC1 [63] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.8.12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.9.1

Summary

All automatic variables shall have been assigned a value before being used. (See page 41 of MISRA-C-2004 [62] .)

Description

Notes:

  • This does not necessarily require initialization at the declaration.

  • Initializing any one member of a union is not considered as (proper) initialization of the other members.

Implementation

Reports if an automatic variable may be used without initialization.

Imprecision

Cautions are reported when the checker cannot determine the necessary execution order.

Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}

Configuration

See generic service options.

Option member_areas
member_areas
-config=MC2.9.1,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=MC2.9.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MC2.9.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.9.2

Summary

Braces shall be used to indicate and match the structure in the non-zero initialisation of arrays and structures. (See page 42 of MISRA-C-2004 [62] , page 14 of MISRA-C-2004-TC1 [63] .)

Description

Notes:

  • Zero initialization is non-compliant unless it is at the top level and non-empty.

  • The rule allows top-level zero initialization because, according to page 14 of MISRA-C:2004 TC1 [63] , usage of shorthand form zero-initialization (i.e., zero-initializing just the first element of an array or the first field of a struct) is only allowed at the top level. This restriction has been questioned on the MISRA forum thread “9.2 in TC1”.

  • The length of string literals in character array initializers is not checked.

Configuration

See generic service options.

Rule MC2.9.3

Summary

In an enumerator list, the = construct shall not be used to explicitly initialise members other than the first, unless all items are explicitly initialised. (See page 42 of MISRA-C-2004 [62] .)

Description

Each enumeration initializer must satisfy one of the following:

  • none of the enumeration constants are initialised;

  • only the first enumeration constant is initialised;

  • all the enumeration constants are explicitly initialised.

In addition, the expression that defines the value of an enumeration constant must be an integral constant expression that has a value representable as an int; also in the case that only the first enumeration constant is initialised, the value must be small enough so that no subsequent value in the list will exceed the int storage used by enumeration constants (See Section 6.5.2.2 of the C90 standard [34]).

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.9.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.10.1

Summary

The value of an expression of integer type shall not be implicitly converted to a different underlying type if:

  1. it is not a conversion to a wider integer type of the same signedness, or

  2. the expression is complex, or

  3. the expression is not constant and is a function argument, or

  4. the expression is not constant and is a return expression.

(See page 50 of MISRA-C-2004 [62] .)

Description

Notes:

  • the terms underlying type and complex are defined on page 47 of MISRA-C:2004 [62] , Section 6.10.4;

  • by default, expressions expanded from a macro-defined do-while-zero loop idiom (allowed by MISRA Rule 19.4) are ignored. This default can be changed using the -loop_idioms global configuration.

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.10.1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.10.2

Summary

The value of an expression of floating type shall not be implicitly converted to a different type if:

  1. it is not a conversion to a wider floating type, or

  2. the expression is complex, or

  3. the expression is a function argument, or

  4. the expression is a return expression.

(See page 50 of MISRA-C-2004 [62] .)

Description

Note that the term complex is defined on page 49 of MISRA-C:2004 [62] , Section 6.10.5.

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.10.2,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.10.3

Summary

The value of a complex expression of integer type shall only be cast to a type of the same signedness that is no wider than the underlying type of the expression. (See page 53 of MISRA-C-2004 [62] , page 15 of MISRA-C-2004-TC1 [63] .)

Description

Notes:

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.10.3,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.10.4

Summary

The value of a complex expression of floating type shall only be cast to a floating type which is narrower or of the same size. (See page 53 of MISRA-C-2004 [62] , page 15 of MISRA-C-2004-TC1 [63] .)

Description

Note that the term complex is defined on page 49 of MISRA-C:2004 [62] , Section 6.10.5.

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.10.4,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.10.5

Summary

If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand. (See page 53 of MISRA-C-2004 [62] , page 16 of MISRA-C-2004-TC1 [63] .)

Description

One of the following must hold:

  1. the result is immediately cast to the type of the operand;

  2. the result is immediately assigned to an object of the same underlying type as the operand;

  3. the bitwise expression is used as a function argument of the same underlying type as the operator;

  4. the bitwise expression is used as a return expression of a function whose return type is of the same underlying type as the operator.

Notes:

  • the exceptions 2-4 are listed on page 16 of MISRA-C:2004 TC1 [63] ;

  • the term underlying type is defined on page 47 of MISRA-C:2004 [62] , Section 6.10.4.

Configuration

See generic service options.

Rule MC2.10.6

Summary

A U suffix shall be applied to all constants of unsigned type. (See page 54 of MISRA-C-2004 [62] .)

Description

Notes:

  • the context in which the constant is used is not relevant (see the MISRA forum thread “Assigning literal 0 to an unsigned variable”);

  • the compliant use of suffix u is for conformance with the corresponding Rule 7.2 on page 68 of MISRA C:2012 [45] ;

  • the inferred type for the integer constants is based on the table on page 56 of the C99 standard [37].

Configuration

See generic service options.

Option literals
literals
-config=MC2.10.6,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MC2.11.1

Summary

Conversions shall not be performed between a pointer to a function and any type other than an integral type. (See page 55 of MISRA-C-2004 [62] , page 16 of MISRA-C-2004-TC1 [63] .)

Description

For null pointer constants, see the MISRA forum thread “Rule 11.1 and NULL defined as ((void*) 0)”.

Note that also if conversions between function and non-function pointers are covered by MC2.1.1, this service reports them altogether as they might be an extension supported by the compiler.

Configuration

See generic service options.

Option casts
casts
-config=MC2.11.1,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC2.11.2

Summary

Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object type or a pointer to void. (See page 55 of MISRA-C-2004 [62] , page 16 of MISRA-C-2004-TC1 [63] .)

Description

Note that as conversions to and from function pointers are covered by Service MC2.1.1 and Service MC2.11.1, this service does not report conversions between function and non-function pointers.

Configuration

See generic service options.

Option casts
casts
-config=MC2.11.2,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC2.11.3

Summary

A cast should not be performed between a pointer type and an integral type. (See page 56 of MISRA-C-2004 [62] .)

Description

To allow the use of integral constants to pointers that enable (for example) the addressing of hardware memory mapped areas, use the cast_exception service configuration.

Configuration

See generic service options.

Option cast_exception
cast_exception
-config=MC2.11.3,cast_exception=EXCEPTION,...

Specify exceptions.

{EXCEPTION,…}:

exceptions allowed. Accepted members are:

  • CONDS: conditions for exceptions. Accepted forms are:

  • constant_pointee_align: allow an integral constant expression whose mod with destination pointee alignment is 0

  • stmt_matcher(STMT_MATCHER): allow any expression matching STMT_MATCHER (see the -stmt_selector global configuration)

Default:

-config=MC2.11.3,cast_exception={}

Option casts
casts
-config=MC2.11.3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC2.11.4

Summary

A cast should not be performed between a pointer to object type and a different pointer to object type. (See page 56 of MISRA-C-2004 [62] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration.

Configuration

See generic service options.

Option casts
casts
-config=MC2.11.4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC2.11.5

Summary

A cast shall not be performed that removes any const or volatile qualification from the type addressed by a pointer. (See page 56 of MISRA-C-2004 [62] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Casts that remove the const qualifier."
-config=MC2.11.5,casts={unqualify_const,
   "relation(unqualify_const_pointee)"}
-doc="Casts that remove the volatile qualifier."
-config=MC2.11.5,casts={unqualify_volatile,
   "relation(unqualify_volatile_pointee)"}

reports concerning conversions that remove the const qualifier will have the tag unqualify_const while reports concerning conversions that remove the volatile qualifier will have the tag unqualify_volatile.

Configuration

See generic service options.

Option casts
casts
-config=MC2.11.5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC2.12.1

Summary

Limited dependence should be placed on C’s operator precedence rules in expressions. (See page 56 of MISRA-C-2004 [62] , page 17 of MISRA-C-2004-TC1 [63] .)

Description

Reports an expression if any of the following hold:

  • The expression is conditional and has a conditional or binary sub-expression.

  • The expression has the form E0 OP1 E1 OP2 E2 where OP1 and OP2 are assignment operators.

  • The expression has the form E0 OP1 E1 OP2 E2 where OP1 is a relational, equality, logical or arithmetic operator, OP2 is any binary operator and OP1 differs from OP2.

  • The expression has the form E0 OP E1 OP E2 where OP is a relational or equality operator or an arithmetic operator other than + and *.

  • The expression has the form E0 OP E1 OP E2 where OP is + and * and one of E0, E1, E2 has a non-integral type.

  • The expression has one of the forms:

    • E0 + E1 +En,

    • E0 * E1 *En

where:

  • the promoted types of E0, …, En are all integral,

  • Ei (0 =< i =< n) is an expression whose promoted type Ii has maximal rank (where there are expressions whose promoted types have the same maximal rank but some are signed and some are unsigned, the first expression with the unsigned type is selected),

  • there are at least two other expressions in E0, …, En whose promoted types either have strictly lower rank than Ii or have the same rank but Ii is unsigned and the other type is signed.

The trusted_pairs service configuration can be used to specify report tags for selected pairs of operators where the first matches the expression’s main operator and the second matches an operator of one of its operands. For example:

-doc="Programmers are aware of the precedence between relational and arithmetic operators, no developer confusion possible."
-config=MC2.12.1,trusted_pairs={safe, "relational:arithmetic"}

will deviate reports for expressions such as a > b+c and b+c < a.

Note that, as Service MC2.12.5 is a special case of this service, duplicate reports are mandated.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MC2.12.1,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MC2.12.2

Summary

The value of an expression shall be the same under any order of evaluation that the standard permits. (See page 58 of MISRA-C-2004 [62] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule MC2.12.3

Summary

The sizeof operator shall not be used on expressions that contain side effects. (See page 60 of MISRA-C-2004 [62] , page 17 of MISRA-C-2004-TC1 [63] .)

Configuration

See generic service options.

Option effects
effects
-config=MC2.12.3,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC2.12.4

Summary

The right-hand operand of a logical && or || operator shall not contain side effects. (See page 60 of MISRA-C-2004 [62] .)

Description

It is assumed that a call to a function has side effects unless the call is declared to have impact property const, pure or noeffect.

The -call_properties global configuration can be used to specify the call property. For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when the right operand is a call to a function not declared to be noeffect.

Configuration

See generic service options.

Option effects
effects
-config=MC2.12.4,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC2.12.5

Summary

The operands of a logical && or || shall be primary-expressions. (See page 61 of MISRA-C-2004 [62] .)

Description

Note that, as this rule is a special case of Service MC2.12.1, duplicate reports are mandated.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MC2.12.5,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MC2.12.6

Summary

The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, != and ?:). (See page 62 of MISRA-C-2004 [62] , page 17 of MISRA-C-2004-TC1 [63] .)

Description

To be more specific:

  1. Any operand of the logical operators && or || or ! must be effectively Boolean;

  2. Expressions that are effectively Boolean must only be used in one of the following ways:

    1. as operands of &&, ||, !, =, ==, or !=,

    2. as arguments to function calls where the corresponding parameter also has effectively Boolean type,

    3. in a return statement where the return type is effectively Boolean,

    4. for an object initialization where the type of the object being initialized is effectively Boolean.

See “Boolean expressions” in the Glossary, page 118 of MISRA-C:2004 [62] for a definition of effectively Boolean.

Note that items 2 (b), (c) and (d) in this variant of the MISRA Rule 12.6 are based on the MISRA forum thread “Rule 12.6 and functions taking/returning Boolean values”. where the following points are made:

  1. The function call operator should have been included in this list with the caveat that expressions with effectively Boolean type may be used in the argument list where the corresponding parameter also has effectively Boolean type.

  2. An expression with effectively Boolean type may also be used in a return statement and also to initialise an object but Rule 12.6 does not apply to these cases because there are no operators present.

  3. There is no rule for effectively Boolean types corresponding to Rule 6.1, although it would clearly be sensible to write code as if such a rule did exist.

Thus, for example, the three uses of TRUE in the following code will all be marked as non-compliant:

int foo(void) {
  int a = TRUE;
  a = TRUE;
  return TRUE;
}

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.12.6,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.12.6L

Summary

The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, != and ?:). (See page 62 of MISRA-C-2004 [62] , page 17 of MISRA-C-2004-TC1 [63] .)

Description

To be more specific:

  1. Any operand of the logical operators && or || or ! must be effectively Boolean;

  2. Expressions that are effectively Boolean must only be used as operands for ||, !, =, ==, or !=.

See “Boolean expressions” in the Glossary, page 118 of MISRA-C:2004 [62] for a definition of effectively Boolean.

Note that, compared to MC2.12.6, this rule (MC2.12.6L) is a stricter interpretation of MISRA Rule 12.6 for the use of effectively Boolean expressions, so that, for example, only the assignment on line 3 will be marked as non-compliant in the following code:

int foo(void) {
  int a = TRUE;
  a = TRUE;
  return TRUE;
}

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.12.6L,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.12.7

Summary

Bitwise operators shall not be applied to operands whose underlying type is signed. (See page 62 of MISRA-C-2004 [62] , page 18 of MISRA-C-2004-TC1 [63] , page 17 of MISRA-C-2004-Permits-1 [65] .)

Description

Note that the term underlying type is defined in Section 6.10.4, page 47 of MISRA-C:2004 [62] .

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.12.7,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.12.8

Summary

The right-hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left-hand operand. (See page 62 of MISRA-C-2004 [62] .)

Description

Any shift operator (<<, >>) is non-compliant if:

  • it is in the object sources and either the right-hand side is a non-constant expression or its value is a known constant value that is negative or is greater than or equal to the width in bits of the underlying type of the left-hand side; or

  • it is in the non-skipped compiled file contents in a preprocessor conditional expressions and either the right-hand side is unexpanded or its value is negative or greater than or equal to the width in bits of the underlying type of the left-hand side.

Imprecision

Cautions are reported when values on the right-hand side of shift operators have not been determined.

Configuration

See generic service options.

Rule MC2.12.9

Summary

The unary minus operator shall not be applied to an expression whose underlying type is unsigned. (See page 62 of MISRA-C-2004 [62] .)

Description

See Section 6.10.4, page 47 of MISRA-C:2004 [62] for a definition of underlying type.

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.12.9,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.12.10

Summary

The comma operator shall not be used. (See page 63 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option statements
statements
-config=MC2.12.10,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC2.12.10,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC2.12.11

Summary

Evaluation of constant unsigned integer expressions should not lead to wrap-around. (See page 63 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Rule MC2.12.12

Summary

The underlying bit representations of floating-point values shall not be used. (See page 64 of MISRA-C-2004 [62] .)

Description

The service will report:

  • any type conversion between a pointer to a floating-point type and a pointer to any other type, unless the conversion maps a pointer to (array of) floating-point type to a pointer to (array of) the same floating-point type, where the number and size of array constructions may differ;

  • any object declaration with union type that has a member with floating-point type;

  • any object declaration with a (possibly recursive) struct type that has a single member with union type and this has a member of floating-point type;

  • if a union type with a member of floating-point type is referred to by a compound literal expression.

Note that the service has false positives with respect to the original (undecidable) MISRA rule.

For example, any cast of a pointer to a floating-point type to a pointer to int will be reported although, in general, this will not lead to accessing the underlying floating-point representation (see the MISRA forum thread “MISRA C - Rule 12.12”).

Imprecision

False positives are reported because the checker may not be sure if there is access to the memory area where a floating point object is stored.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.12.12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option casts
casts
-config=MC2.12.12,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MC2.12.13

Summary

The increment (++) and decrement (--) operators should not be mixed with other operators in an expression. (See page 64 of MISRA-C-2004 [62] , page 18 of MISRA-C-2004-TC1 [63] .)

Description

The service will report any full expression (that is, any expression that is not a child of another expression) that contains an increment or decrement operator and either the value of the expression is used or the expression has at least one other side effect.

See both:

Configuration

See generic service options.

Option effects
effects
-config=MC2.12.13,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MC2.13.1

Summary

Assignment operators shall not be used in expressions that yield a Boolean value. (See page 64 of MISRA-C-2004 [62] .)

Description

The service will report any use of a simple or compound assignment operator:

  • as an operand of &&, ||, !, <, <=, >, >=, ==, or !=;

  • in the condition part of the :? operator;

  • in the condition part of an if, do, for, or while statement.

Configuration

See generic service options.

Option statements
statements
-config=MC2.13.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC2.13.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC2.13.2

Summary

Tests of a value against zero should be made explicit, unless the operand is effectively Boolean. (See page 65 of MISRA-C-2004 [62] .)

Description

Expressions that have an effectively Boolean type must be used in one of the following ways:

  • as an operand of &&, ||, !;

  • in the condition part of the ?: operator;

  • in the condition part of an if, do, for, or while statement;

  • as the operand of a cast (implicitly or explicitly) to a Boolean type.

The service ignores the integer literal 0 when used for the condition part of a macro-expanded do-while-zero.

See “Boolean expressions” in the Glossary, page 118 of MISRA-C:2004 [62] for a definition of effectively Boolean.

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.13.2,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.13.3

Summary

Floating-point expressions shall not be tested for equality or inequality. (See page 66 of MISRA-C-2004 [62] .)

Description

Floating-point expressions are non-compliant if they are used:

  1. as operands f1 and f2 in explicit equality and inequality comparisons f1 == f2 and f1 != f2;

  2. as arguments to boolean operators &&, || or !;

  3. as the conditions for if, for, do, and while statements;

  4. in indirect tests for equality for floating point expressions (f1 op1 f2) && (f3 op2 f4), where op1 and op2 are relational operators <=, >=, < or > and either op1 is the inverse of op2, the expressions f1 and f3 are equivalent, and the expressions f2, f4 are equivalent, or op1 and op2 are the same, the expressions f1, f4 are equivalent and the expressions f2, f3 are equivalent.

Note that in item 4, expressions e1, e2 are taken to be equivalent, if, after dropping any parentheses and unary + operators:

  • they are the same variable or literal;

  • have the same operator and have equivalent arguments;

  • have the forms f1 op f2 and f3 op f4 where op is a non-assignment binary operator, the expressions f1, f3 are equivalent and the expressions f2, f4 are equivalent or op is one of the commuting operators + or * and the expressions f1, f4 are equivalent and the expressions f2, f3 are equivalent.

Exceptions

Note that comparison with 0.0 can be exempted using the statements service configuration.

Imprecision

false negatives are present because recognising indirect equality and inequality tests is undecidable

For example, the following function, depending on the definition of g() might or might not test the equality of x and y:

float* p;
int f(float x, float y) {
  if (x < y)
    return 0;
  *p = y;
  g();
  if (-*p < -y)
    return 0;
  return 1;
}

Said that, the rule captures most (if not all) reasonable ways in which a programmer in good-faith (i.e., not deliberately attempting to break the rule) might code an equality/inequality test on floating-point expressions.

Configuration

See generic service options.

Option statements
statements
-config=MC2.13.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option ignored_stmts
ignored_stmts
-config=MC2.13.3,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MC2.13.4

Summary

The controlling expression of a for statement shall not contain any objects of floating type. (See page 66 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Rule MC2.13.5

Summary

The three expressions of a for statement shall be concerned only with loop control. (See page 66 of MISRA-C-2004 [62] , page 18 of MISRA-C-2004-TC1 [63] .)

Description

The for statement must satisfy a number of conditions.

  1. The three parts of the head of a for statement (refrerred to here, in the order in which they occur, as the before part, condition part and after part):

    • must all be empty; or

    • the before part is empty (and the loop counter should already be initialized) and the condition part and after parts are present or

    • all three parts must all be present.

Note that if the for statement has a non-compliant structure, then the report can be tagged using for_structure service configuration. For example:

-doc="For loops with a non-empty condition and an empty after part."
-config=MC2.13.5,for_structure={struct_tag, "cond(non_empty)&&after(empty)"}

will tag the violation report for a for statement where the head has a non-empty condition part and an empty after part.

  1. The conditions for a for statement where at least the condition and after parts are non-empty depend on the concept of a loop counter and on the more general concept of a control variable. For this lax variant of 13.5 these are defined as follows:

    • a control variable is any variable, array subscript expression, or member expression that has scalar type and is declared or referred to in the head 0f the for statement;

    • for this variant of Rule 13.5, a lax meaning for a loop counter is used

      • it is a control variable,

      • its type is scalar,

      • it is initialized in the before part or initialized prior to the for statement,

      • it is modified in the after part,

      • its address is never taken,

      • it is not global,

      • there must be only one loop counter.

Note that if the loop counter is non-compliant or there is more than one loop counter, then the report relating to this can be tagged using for_counter service configuration. For example:

-doc="For loops with multiple loop counters."
-config=MC2.13.5,for_counter+={multi_tag, "!single()"}}

will tag the violation report for a for statement that has more than one loop counter.

  1. The three parts of a for statement head and its body must satisfy the following conditions:

    • the before part may only be used for initialising the loop counter;

    • the condition part is a non-empty boolean combination of relational or (dis)equality tests (tests can be direct) and function calls such that

      • one of the tests refers to a loop counter,

      • the resulting boolean function is not identically true;

    • the after part is non-empty and only modifies the loop counter, incrementing or decrementing it by a constant or an expression which evaluates to the same value for the duration of the loop;

    • the body of the for statement must not modify the loop counter or any other non-boolean control variable.

Note that if any of the parts of a for statement are non-compliant, then the report relating to the parts can be tagged using for_parts service configuration. For example:

-doc="For loops with a before part that initializes more than one variable."
-config=MC2.13.5,for_parts={only_init_tag, "before(only_init)"}

will tag the violation report for a for statement when the before part of the head initializes (by means of assignments or definitions) more than one variable (assuming that the structure and loop counter are compliant).

Additional notes:

  • this meaning is based on the description on page 66 of MISRA-C:2004 [62] , the modifications given on page 18 of MISRA-C:2004 TC1 [63] and the more exact requirements given by the MISRA forum threads:

  • In the MISRA forum thread “for() loops - does simplicity matter?” it is said “The concept of a loop counter is not well-defined. In order to assist in identifying loop counters, tools may impose restrictions on the loop and may report violations of this rule even though the code is compliant”. So for this variant MC2.13.5, we have taken the weaker requirement given in MISRA forum thread “13.5 Loop control expression inconsistencies” which says “a Loop Counter is involved in the decision to terminate the loop in the second expression of the for statement” and then added enough restrictions to ensure the rule is decidable.

Imprecision

Cautions are reported when the analyzer cannot determine if all the conditions are fully satisfied.

Cautions are reported when:

  • the analyzer cannot determine if the loop counter will be monotonically incremented or decremented;

  • the analyzer cannot determine if a control variable that is not a loop counter and does not have Boolean type maybe modified in the body;

  • the non-const address of a control variable is taken and used.

Configuration

See generic service options.

Option for_structure
for_structure
-config=MC2.13.5,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=MC2.13.5,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=MC2.13.5,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MC2.13.5S

Summary

The three expressions of a for statement shall be concerned only with loop control. (See page 66 of MISRA-C-2004 [62] , page 18 of MISRA-C-2004-TC1 [63] .)

Description

The for statement must satisfy a number of conditions.

  1. The three parts of the head of a for statement (refrerred to here, in the order in which they occur, as the before part, condition part and after part):

    • must all be empty; or

    • the before part is empty (and the loop counter should already be initialized) and the condition part and after parts are present or

    • all three parts must all be present.

Note that if the for statement has a non-compliant structure, then the report can be tagged using for_structure service configuration. For example:

-doc="For loops with a non-empty condition and an empty after part."
-config=MC2.13.5S,for_structure={struct_tag, "cond(non_empty)&&after(empty)"}

will tag the violation report for a for statement where the head has a non-empty condition part and an empty after part.

  1. The conditions for a for statement where at least the condition and after parts are non-empty depend on the concept of a loop counter and on the more general concept of a control variable. For this strict variant of 13.5 these are defined as follows:

    • a control variable is any variable, array subscript expression, or member expression that has scalar type and is declared or referred to in the head 0f the for statement;

    • for this variant of Rule 13.5S, a strict meaning for a loop counter is used

      • it is a control variable,

      • its type is scalar,

      • it is not an array subscript expression or member expression (i.e., a variable),

      • it is initialized in the before part or initialized prior to the for statement,

      • it is involved in the decision to terminate the loop in the condition part,

      • it is modified in the after part,

      • its address is never taken in the context of the function definition,

      • it is not global,

      • there must be only one loop counter.

Note that if the loop counter is non-compliant or there is more than one loop counter, then the report relating to this can be tagged using for_counter service configuration. For example:

-doc="For loops with multiple loop counters."
-config=MC2.13.5S,for_counter+={multi_tag, "!single()"}}

will tag the violation report for a for statement that has more than one loop counter.

  1. The three parts of a for statement head and its body must satisfy the following conditions:

    • the before part may only be used for initialising the loop counter;

    • the condition part is a non-empty boolean combination of relational or (dis)equality tests (tests can be direct) and function calls such that

      • each simple test (i.e., not a conjunction or disjunction) that involves the loop counter is relational and where one argument is the counter and the other argument is either a constant of known value or an integral non-global untaken variable whose type is not volatile, that is not modified in the for statement,

      • the loop counter is passed in exactly one argument to a function call,

      • the resulting boolean function is not identically true;

    • the after part must increment or decrement the loop counter by means of a single write expression where the change for each iteration is a constant expression which evaluates to the same value for the duration of the loop and where the direction of change guarantees loop termination;

    • the body of the for statement must not modify the loop counter or any other non-boolean control variable and have no goto or label statement.

Note that if any of the parts of a for statement are non-compliant, then the report relating to the parts can be tagged using for_parts service configuration. For example:

-doc="For loops with a before part that initializes more than one variable."
-config=MC2.13.5S,for_parts={only_init_tag, "before(only_init)"}

will tag the violation report for a for statement when the before part of the head initializes (by means of assignments or definitions) more than one variable (assuming that the structure and loop counter are compliant).

Additional notes:

  • this meaning is based on the description on page 66 of MISRA-C:2004 [62] , the modifications given on page 18 of MISRA-C:2004 TC1 [63] and the more exact requirements given by the MISRA forum threads:

  • In the MISRA forum thread “for() loops - does simplicity matter?” it is said “The concept of a loop counter is not well-defined. In order to assist in identifying loop counters, tools may impose restrictions on the loop and may report violations of this rule even though the code is compliant”. So for this variant MC2.13.5S, we have taken the stronger requirement given in MISRA forum thread “for() loops” which says that in the second expression, the loop counter must be the operand of a relational operator and then we have added enough restrictions to ensure the rule is decidable.

Imprecision

Cautions are reported when the analyzer cannot determine if all the conditions are fully satisfied.

Cautions are reported when:

  • the analyzer cannot determine if the loop counter will be monotonically incremented or decremented;

  • the analyzer cannot determine if a control variable that is not a loop counter and does not have Boolean type maybe modified in the body;

  • the non-const address of a control variable is taken and used.

Configuration

See generic service options.

Option for_structure
for_structure
-config=MC2.13.5S,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=MC2.13.5S,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=MC2.13.5S,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MC2.13.6

Summary

Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop. (See page 67 of MISRA-C-2004 [62] .)

Description

A loop counter is a variable that is modified in the last part of the for statement head.

If it cannot be proved that a numeric loop counter in a for statement is not be modified in the loop body or its address is not taken in the function body, then the loop counter will be reported.

Imprecision

Cautions are reported when the checker is uncertain whether the loop counter conditions are fully satisfied.

Configuration

See generic service options.

Rule MC2.13.7

Summary

Boolean operations whose results are invariant shall not be permitted. (See page 67 of MISRA-C-2004 [62] , page 21 of MISRA-C-2004-Permits-1 [65] .)

Description

Notes:

  • An expression is taken to be Boolean if it is:

    • an operand of &&, ||, !, <, <=, >, >=, ==, or !=;

    • the condition part of the :? operator;

    • the condition part of an if, do, for, or while statement.

  • Expressions in a compile-time constant context are not reported.

  • By default, expressions expanded from a macro-defined do-while-zero loop idiom (allowed by MISRA Rule 19.4) are ignored. This default can be changed using the -loop_idioms global configuration.

Implementation

Reports a Boolean operation (either implicit or explicit) if it can be detected that the expression will always have the same value.

Imprecision

False negatives are present because, in general, the value of a Boolean operation is not statically known.

Configuration

See generic service options.

Rule MC2.14.1

Summary

There shall be no unreachable code. (See page 68 of MISRA-C-2004 [62] , page 19 of MISRA-C-2004-TC1 [63] , page 25 of MISRA-C-2004-Permits-1 [65] .)

Description

The service reports:

  • defined functions that are not referenced;

  • unreachable code;

  • constant unfeasible code.

Notes:

  • the MISRA forum thread “14.1 There shall be no unreachable code” confirms that this rule is only concerned with code for which the syntax does not permit it to be accessed.

  • A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

  • Reports for deliberately unreachable statements and expressions can be tagged using the statements service configuration.

  • Unused declarations can be tagged using the declarations service configuration; in particular, to hide declarations in public API files by:

    • using the tag hide;

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library entry points not necessarily have to be referenced."
-config=MC2.14.1,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Imprecision

False negatives are present because the checker is not able to determine precisely whether code is unreachable.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.14.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_stmts
ignored_stmts
-config=MC2.14.1,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option statements
statements
-config=MC2.14.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option all_decls
all_decls
-config=MC2.14.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option diagnostics
diagnostics
-config=MC2.14.1,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MC2.14.2

Summary

All non-null statements shall either:

  1. have at least one side-effect however executed, or

  2. cause control flow to change.

(See page 68 of MISRA-C-2004 [62] .)

Description

Notes:

  • the side effect must be caused by the external operator/functor of the expression (and not just an effect of its sub-expressions);

  • explicit cast to void is not reported (see the corresponding Rule 2.2 on page 41 of MISRA C:2012 [45] ).

Imprecision

False positives are reported when there are function calls and it is not known if the called function has side effects.

Configuration

See generic service options.

Rule MC2.14.3

Summary

Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment provided that the first character following the null statement is a white-space character. (See page 69 of MISRA-C-2004 [62] .)

Description

A null statement is reported if:

  • it is not be preceded on the same source line by a comment;

  • it is not immediately followed by any character other than a white space character;

  • there is text apart from white-space characters and comments on the same source line.

Configuration

See generic service options.

Rule MC2.14.4

Summary

The goto statement shall not be used. (See page 69 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option statements
statements
-config=MC2.14.4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC2.14.4,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC2.14.5

Summary

The continue statement shall not be used. (See page 69 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option statements
statements
-config=MC2.14.5,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC2.14.5,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC2.14.6

Summary

For any iteration statement there shall be at most one break statement used for loop termination. (See page 69 of MISRA-C-2004 [62] .)

Description

Note that whether or not one of these break statements is unreachable is not taken into account by this rule.

Configuration

See generic service options.

Rule MC2.14.7

Summary

A function shall have a single point of exit at the end of the function. (See page 69 of MISRA-C-2004 [62] .)

Description

It is reported if a function does not have a single point of exit at the end of the function block. Notes:

  • what constitutes a function exit node can be specified by means of the exit_kind service configuration;

  • what constitutes an end position of a function can be specified by mean of the end_position service configuration.

For example, with the configure lines:

-doc_begin="Return statements and calls to noreturn functions may only occur at the end or at the end of a try block or catch handler."
-config=MC2.14.7,!exit_kind=
   {return, only_at_end_position, true},
   {noreturn_call, only_at_end_position, true}
-config=MC2.14.7,end_position+={
   {compound_try, compound_catch}, true}
-doc_end

the return statements and calls to functions with the noreturn property are considered to be function exits and these exits may only occur at the end of the function body or at the end of a try block or catch handler when last statement of the function body is the handled try block.

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=MC2.14.7,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=MC2.14.7,exit_kind={return, only_at_end_position, true},
  {noreturn_call, anywhere, true}

Option end_position
end_position
-config=MC2.14.7,end_position={{POS,...}, END},...

Specify the end positions and if an exit node is required.

The configuration’s content is a list of the end positions and if a exit kind node is required at that position.

{POS,…}:

end position in the function body. Accepted members are:

  • compound: the end of the body when the body is a compound statement;

  • try: the end of the body when the body is a try block;

  • catch: the end of a catch handler when the body is a try block;

  • compound_try: the end of a try block when last statement of the function body is the try block;

  • compound_catch: the end of a catch handler when last statement of the function body is the handled try block;

END:

whether the exit position must always have an exit kind node. Accepted values are:

  • true: the exit position must always have an exit node;

  • false: the exit position does not have to have an exit node;

Default:

-config=MC2.14.7,end_position={{compound, try}, false}

Rule MC2.14.8

Summary

The statement forming the body of a switch, while, dowhile or for statement shall be a compound statement. (See page 69 of MISRA-C-2004 [62] , page 25 of MISRA-C-2004-TC1 [63] .)

Configuration

See generic service options.

Rule MC2.14.9

Summary

An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement. (See page 70 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Rule MC2.14.10

Summary

All if ... else if constructs shall be terminated with an else clause. (See page 70 of MISRA-C-2004 [62] , page 19 of MISRA-C-2004-TC1 [63] .)

Description

The service will report any if statement if the final else if:

  • has no else clause,

  • has an else clause that is the null statement, or

  • has an else clause that is an empty compound statement and there is no comment as to why it is empty.

The default configuration does not check the content or style of the comment; however the else_empty service configuration can be used to provide a comment matcher.

Configuration

See generic service options.

Option else_empty
else_empty
-config=MC2.14.10,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC2.14.10,else_empty={missing, "none()"}, {null, "none()"}, {empty_compound, "any()"}

Option ignored_comments
ignored_comments
-config=MC2.14.10,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC2.15.0

Summary

The preamble normative text in section 15 shall be treated as Rule 15.0. Any deviation from the normative text shall be considered a non-compliance if no other rule in section 15 is not complied with. (See page 71 of MISRA-C-2004 [62] , page 19 of MISRA-C-2004-TC1 [63] .)

Description

The service reports if one of the following does not hold:

  • the body of the switch statement is a compound statement;

  • the first statement of the body is a case statement;

  • each declaration occurs at the beginning of a compound statement;

  • each break statement is the last statement of a case or default clause;

  • each statement in the body is one of the following:

    • null statement,

    • case statement,

    • default statement,

    • iteration statement,

    • selection statement,

    • return statement.

Configuration

See generic service options.

Option terminals
terminals
-config=MC2.15.0,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MC2.15.0,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC2.15.0,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC2.15.1

Summary

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement. (See page 72 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option switch_clauses
switch_clauses
-config=MC2.15.1,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC2.15.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC2.15.2

Summary

An unconditional break statement shall terminate every non-empty switch clause. (See page 72 of MISRA-C-2004 [62] .)

Description

Note that in the introductory text for Section 6.15, page 71 of MISRA-C:2004 [62] a case or default clause is defined to be the sequence of statements (excluding any case or default label statements) starting with the case or default label statement and finishing at the next case or default statement or at the end of the compound statement forming the body of a switch statement.

For terminating statements other than break, the reports can be tagged by means of the terminals service configuration.

For example, with the configure line:

-doc="Terminals statements with a noreturn function are safe."
-config=MC2.15.2,terminals={safe,"call(property(noreturn))"}

if the last statement of the case or default clause is a call to a function with the noreturn property, then the report will have the tag safe.

Configuration

See generic service options.

Option terminals
terminals
-config=MC2.15.2,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MC2.15.2,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC2.15.2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC2.15.3

Summary

The final clause of a switch statement shall be the default clause. (See page 72 of MISRA-C-2004 [62] , page 19 of MISRA-C-2004-TC1 [63] .)

Description

A comment may be used in place of the default clause as a possible acceptable alternative). To specify the allowed form of the comment use the replacement_comment service configuration.

For example, with the configuration line:

-doc="Only Fall through to next statement comments are accepted in place of the default clause."
-config=MC2.15.3,
   +replacement_comment={missing_terminal,
      "^.*([fF]all[- ]?[tT]hr(ough|u)|FALL[- ]?THR(OUGH|U))(s?).*$"}

the service will accept comments such as

Fall through to next statement

but not other comments such as

no default needed

as acceptible alternatives to a default clause.

Note that in the introductory text for Section 6.15, page 71 of MISRA-C:2004 [62] , a case or default clause is defined to be the sequence of statements (excluding any case or default label statements) starting with the case or default label statement and finishing at the next case or default statement or at the end of the compound statement forming the body of a switch statement.

Configuration

See generic service options.

Option replacement_comment
replacement_comment
-config=MC2.15.3,replacement_comment={WHEN, COMMENT_MATCHER},...

Specify matchers for replacement comments.

The configuration’s content is a list of pairs indicating when a comment is needed and a comment matcher.

WHEN:

when to check a comment replacement. Accepted values are:

  • empty_default: switch default clause is empty;

  • missing_terminal: case or default clause has no terminal statement;

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MC2.15.3,replacement_comment={empty_default,
    "any()"}

Option switch_clauses
switch_clauses
-config=MC2.15.3,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MC2.15.3,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MC2.15.4

Summary

A switch expression shall not represent a value that is effectively Boolean. (See page 73 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MC2.15.4,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MC2.15.5

Summary

Every switch statement shall have at least one case clause. (See page 73 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.15.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.16.1

Summary

Functions shall not be defined with a variable number of arguments. (See page 74 of MISRA-C-2004 [62] .)

Description

More specifically, the rule reports:

  • any user-defined function whose definition uses ellipsis;

  • any #include with stdarg.h;

  • no use of any standard library entities va_arg, va_start and va_end either as a macro or as an object or function).

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.16.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC2.16.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.16.2

Summary

Functions shall not call themselves, either directly or indirectly. (See page 74 of MISRA-C-2004 [62] .)

Description

For any function that is non-compliant, the report will show all calls in the chain that lead to it calling itself.

Imprecision

Cautions are reported when the recursion relies on indirect function calls to form the chain.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.16.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=MC2.16.2,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule MC2.16.3

Summary

Identifiers shall be given for all of the parameters in a function prototype declaration. (See page 74 of MISRA-C-2004 [62] .)

Description

Note that this includes the cases described by the MISRA forum thread “16.3” which adds: “it should apply to all prototypes. A declaration of a function pointer should specify the parameter names […]. Any type-casts to function pointer types should also specify the parameter names in the prototype.”.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.16.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.16.4

Summary

The identifiers used in the declaration and definition of a function shall be identical. (See page 74 of MISRA-C-2004 [62] .)

Description

Note that missing identifiers are ignored by this rule (see the MISRA forum thread “Is 16.4 violated if 16.3 is?”).

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.16.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.16.5

Summary

Functions with no parameters shall be declared and defined with parameter type void. (See page 74 of MISRA-C-2004 [62] , page 20 of MISRA-C-2004-TC1 [63] .)

Description

Note that this rule does not report function pointers (see the note in the MISRA forum thread “Rule 16.5”.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.16.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.16.6

Summary

The number of arguments passed to a function shall match the number of parameters. (See page 74 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option calls
calls
-config=MC2.16.6,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=MC2.16.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.16.7

Summary

A pointer parameter in a function prototype should be declared as pointer to const if the pointer is not used to modify the addressed object. (See page 75 of MISRA-C-2004 [62] .)

Description

Notes:

  • Any pointer parameter that is not used to modify the addressed object must be declared as pointer to const

  • Similarly, any array whose elements are not modified must declare the elements as const.

  • The parameters for any functions such as main that have a fixed signature are ignored.

  • To restrict the declarations that are shown, use the show_declarations service configuration.

For example, the following configure line will restrict the reporting to only those function declarations that must have their constness changed to be congruent to corresponding parameters in the function definition:

-doc="Report only functions that must have their constness changed to be congruent to the definition."
-config=MC2.16.7,show_declarations,non_param

Imprecision

False negatives are present because the single unit analyzer does not check pointers with program scope.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=MC2.16.7,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=MC2.16.7,show_declarations=all

Option declarations
declarations
-config=MC2.16.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MC2.16.7,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MC2.16.7,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MC2.16.8

Summary

All exit paths from a function with non-void return type shall have an explicit return statement with an expression. (See page 75 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option statements
statements
-config=MC2.16.8,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC2.16.8,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=MC2.16.8,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MC2.16.9

Summary

A function identifier shall only be used with either a preceding &, or with a parenthesised parameter list, which may be empty. (See page 75 of MISRA-C-2004 [62] .)

Description

Note that the rule uses the semantic interpretation with respect to the phrase preceded by, as described in MISRA forum thread “Rule 16.9”.

Configuration

See generic service options.

Option statements
statements
-config=MC2.16.9,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC2.16.9,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC2.16.10

Summary

If a function returns error information, then that error information shall be tested. (See page 76 of MISRA-C-2004 [62] .)

Description

Calls to standard library functions whose return values contain error information are always checked.

To specify functions not in the standard library that return error information use the -call_properties global configuration with property error.

An error-returning function call is compliant if any of the following hold.

  • The returned value is tested directly and the result of the test is used.

  • The returned value is returned directly to the calling function which must have a similar error value expectation (that is, with the same error configuration).

  • The returned value is stored in a variable and that variable is tested in a statement that immediately follows the call in one of the following ways:

    • the test is in the condition part of an if statement;

    • the variable is in the condition expression of a switch statement, and the case and default labels select the specified error values;

    • it is a return statement that returns the result of the test.

Note that to specify the handling of a function’s error values use the handling service configuration.

For example, the configuration line:

-doc="The return value of functions matching __return_cast_minusone_errors must be assigned to a variable whose name starts with time_, then verified and returned."
-config=MC2.16.10,handling+={"any()", __return_cast_minusone_errors,
if, {{return_cast_minusone_tag, "return(ref(^(time_).*$))", ""}}}

specifies that for any called function with an error property that matches the selector __return_minusone_errors, (this is a builtin selector for the -function_error global configuration, that requires the error value, returned by the called function, to be -1), then:

  • the return value must be assigned to a variable that matches ^(time_).*$,

  • the variable must be tested in the condition part of an if statement and

  • returned by the calling function.

If the handling for the function error is not specified, then there is no check on any action taken when an error value is returned.

Configuration

See generic service options.

Option calls
calls
-config=MC2.16.10,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option handling
handling
-config=MC2.16.10,handling={DECL_MATCHER, ID, SLCT, {{TAG, ACTION, FMT},...}},...

Specify the error handling.

The configuration’s content is an ordered list of a declaration matcher for the calling function, an error identifier and associated data about where the error is placed, where it should be tested and what actions should be taken.

Note that the first matching clause for the calling function and error identifier will be selected and the error value is checked using the associated data

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

ID:

an identifier declared in the -function_error global configuration.

SLCT:

specifies if handling is in a switch or if statement. Accepted values are:

  • any: any selection;

  • if: if statement;

  • switch: switch statement;

TAG:

a value tag declared in the -function_error global configuration.

ACTION:

action to be taken at end of related error branch. Accepted forms are:

  • any: the action is not checked

  • return_any(): the action is to return

  • return(RETURN_VAL): the action is to return RETURN_VAL

  • return_minus(RETURN_VAL): the action is to return the negated RETURN_VAL

  • return_call(CALL_MATCHER,RETURN_VAL): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression) where the RETURN_VAL is an argument to the call; the called function must have a noreturn attribute (see the -decl_properties global configuration)

  • goto(REGEX): the action is a goto statement with label matching REGEX

  • throw(TYPE_MATCHER): the action is a throw statement with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • call(CALL_MATCHER): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression)

  • switch(FUNCTION_ERROR): the action is a switch statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

  • if(FUNCTION_ERROR): the action is an if statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

REGEX

accepted forms are:

RETURN_VAL

accepted forms are:

  • return_value(): the returned value

  • INTEGER: the value

  • STMT_MATCHER: a sub-expression of an expression matching STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template callpost__default_fmt) to specify the message describing ACTION.

Default:

-config=MC2.16.10,handling={}

Rule MC2.17.1

Summary

Pointer arithmetic shall only be applied to pointers that address an array or array element. (See page 76 of MISRA-C-2004 [62] , page 28 of MISRA-C-2004-Permits-1 [65] .)

Description

Note that, for this rule, there is no requirement that the pointer has an array type (see the MISRA forum thread “Arithmetic on Pointers are MISRA compliant ?”).

Imprecision

Cautions are reported when the checker is uncertain whether the pointer points to an array.

Configuration

See generic service options.

Rule MC2.17.2

Summary

Pointer subtraction shall only be applied to pointers that address elements of the same array. (See page 76 of MISRA-C-2004 [62] .)

Description

Note that, for this rule, there is no requirement that the pointers have array types (see the MISRA forum thread “Arithmetic on Pointers are MISRA compliant ?”.

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operands with the same allocation identifier are not reported. For example, with the configuration line:

-decl_properties+={"^(data_end|data_start)$", {"alloc_id(alloc_data)"}}
extern char data_start[];
extern const char data_end[];

int main() {
char * p = data_end - data_start;
}

the subtraction data_end-data_start is not reported.

Imprecision

Cautions are reported when the checker is uncertain whether the pointers point to the same array.

Configuration

See generic service options.

Rule MC2.17.3

Summary

>, >=, <, <= shall not be applied to pointer types except where they point to the same array. (See page 76 of MISRA-C-2004 [62] .)

Description

Note that, for this rule, there is no requirement that the pointers have array types (see the MISRA forum thread “Arithmetic on Pointers are MISRA compliant ?”.

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported.

Imprecision

Cautions are reported when the checker is uncertain whether the pointers point to the same object.

Configuration

See generic service options.

Rule MC2.17.4

Summary

Array indexing shall be the only allowed form of pointer arithmetic. (See page 77 of MISRA-C-2004 [62] , page 20 of MISRA-C-2004-TC1 [63] , page 30 of MISRA-C-2004-Permits-1 [65] .)

Configuration

See generic service options.

Option array_arith_exception
array_arith_exception
-config=MC2.17.4,array_arith_exception=EXCEPT,...

Specify exceptions to the rule.

{EXCEPT,…}:

a set of pointer operations. Accepted members are:

  • array_index_reachable: array indexing when all objects reachable from the indexed expression are declared as arrays;

  • array_index_strict: array indexing when the indexed expression is not declared as an array;

  • array_index: array index;

  • add: + operation;

  • add_assign: += operation;

  • sub: - operation;

  • sub_assign: -= operation;

  • preinc: pre increment;

  • postinc: post increment;

  • predec: pre decrement;

  • postdec: post decrement;

  • incdec: any increment or decrement operation;

  • argument_passing: argument passing;

Default:

-config=MC2.17.4,array_arith_exception={}

Option declarations
declarations
-config=MC2.17.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.17.5

Summary

The declaration of objects should contain no more than 2 levels of pointer indirection. (See page 78 of MISRA-C-2004 [62] .)

Description

Also the return type of a function must not have more than 2 levels of pointer indirection; as shown by a test case in the MISRA exemplar test:

static int8_t *** mc2_1705_local2 ( void ); /* Not Compliant */

Configuration

See generic service options.

Rule MC2.17.6

Summary

The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist. (See page 79 of MISRA-C-2004 [62] .)

Imprecision

Cautions are reported when the address is possibly passed in a function call to another automatic object of larger scope or a static object.

Configuration

See generic service options.

Rule MC2.18.1

Summary

All structure and union types shall be complete at the end of a translation unit. (See page 79 of MISRA-C-2004 [62] , page 21 of MISRA-C-2004-TC1 [63] .)

Description

A pointer to an incomplete type is itself complete and is permitted, and therefore the use of opaque pointers is not reported.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.18.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.18.2

Summary

An object shall not be assigned to an overlapping object. (See page 79 of MISRA-C-2004 [62] .)

Description

Note the clarification in the MISRA forum thread “Violation for rule 109” where it states that the rule covers both assignment (Undefined behavior 34) and copying (Undefined behavior 55) using library functions (see the C90 standard [34], Appendix G2).

Implementation

Reports if:

  • a library function other than memmove for copying objects is used to copy (possibly) overlapping objects;

  • a member of a union is copied to another member (or subexpression of another member) of the same union that points to the same allocation area and has incompatible type;

  • a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union.

An exception to the last item is when a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union, both members are arrays and the sub-expressions are array elements with the same type and they are at the same constant offset.

Imprecision

False positives are reported as the checker needs to do a deeper (much more expensive) semantic analysis.

False negatives are present as the checker needs to do a deeper (much more expensive) semantic analysis.

Configuration

See generic service options.

Rule MC2.18.3

Summary

An area of memory shall not be reused for unrelated purposes. (See page 80 of MISRA-C-2004 [62] .)

Description

The default requirement is that the documentation is included in a comment (containing the string MC2.18.3) in one of the project’s source file.

This requirement can be modified using the document service configuration.

To specify which functions should be documented for this rule, use the function_document service configuration; the replacer memory_reuse_comment_repl (see the -replacer global configuration) can be used to select and check the relevant comments for the targeted functions.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MC2.18.3,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option function_document
function_document
-config=MC2.18.3,function_document={ID, DECL, WHERE, WHEN},...

Specify where to find the documentation as a matched comment in the function.

The configuration’s content is a list of documentation ids with where to look and what to look for.

ID:

short name to be used to identify the document.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

WHERE:

position of comment containing documentation relative to function head. Accepted values are:

  • before: comment must be before function definition;

  • begin_body_before_brace: comment must be immediately after the function header and before the initial body {;

  • begin_body_after_brace: comment must be immediately after the initial body { on a new line;

WHEN:

tag indicating when to report. Accepted values are:

  • duplicates: report if more than one matching documentation is found;

  • missing: report if there is no matching documentation;

  • any: report duplicate and missing documentation;

Default:

-config=MC2.18.3,function_document={}

Option document
document
-config=MC2.18.3,document={ID_FMT, SUB, FILE_MATCHER, WHAT, DOC_FMT, REP_FMT},...

Specify how to extrapolate the required documentation from comments in the specified compiled source files.

The configuration’s content is a list of tuples that provide (in order) a unique identifier for the document, context and file matcher indicating where to search for the document, what to check for (e.g., missing documentation), a format for matcher to check the documentation content and a format for the reports.

ID_FMT:

format (see the -fmt global configuration content, template userdocs__id_default_fmt) for short but unique name to identify the document with field:

service

service name.

SUB:

tag indicating subject. Accepted values are:

  • unit: check all files for each translation unit;

  • file: check each file;

  • program: check all the program files;

  • project: check all the project files;

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

WHAT:

tag indicating what to report. Accepted values are:

  • duplicates: report if more than one matching document is found;

  • missing: report if no documentation is found;

  • missing_if_noted: report if no documentation is found and uses are noted;

  • all: report any duplicated or missing documentation;

  • none: do not report missing or duplicated documentation;

DOC_FMT:

format (see the -fmt global configuration content, template userdocs__document_default_fmt) specifying regular expression to match the document content with fields:

document_id

a document identifier;

file

canonical pathname;

rule

rule description;

service

service name.

REP_FMT:

format (see the -fmt global configuration content, template userdocs__default_fmt) for message to be included in the report with fields:

document_id

a document identifier;

file

canonical pathname;

error

message indicating the error kind which can be missing_file, missing_docs or duplicate_docs;

target

unit, program or project description;

service

service name.

Default:

-config=MC2.18.3,document={"%{__id_service_fmt()}", project, "any()", all,
    "%{__document_service_fmt()}",
    "%{__report_service_fmt()}"}

Rule MC2.18.4

Summary

Unions shall not be used. (See page 80 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.18.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MC2.18.4,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MC2.19.1

Summary

#include statements in a file should only be preceded by other preprocessor directives or comments. (See page 83 of MISRA-C-2004 [62] .)

Exceptions

The headers and the exception service configuration allow for some exceptions to this rule.

Configuration

See generic service options.

Option headers
headers
-config=MC2.19.1,headers={TAGS, HEADER_MATCHER},...

Specifies report tags for the #include directives.

The configuration’s content is a list of clauses specifying report tags for matching #include names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

HEADER_MATCHER:

the #include argument matcher including quotes or chevrons. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option exception
exception
-config=MC2.19.1,exception=EXCEPT,...

Specify allowed exceptions to this rule.

{EXCEPT,…}:

allowed exception to this rule. Accepted members are:

  • extern_C: constructs of the form extern "C" {...} are not considered to be code (for ‘C++’ rules);

  • extern_C_only: constructs of the form extern "C" are not considered to be code (for ‘C++’ rules); the following {…} may only contain preprocessor directives;

  • namespace_alias: constructs of the form namespace A = B are not considered to be code;

  • if_directive: directive subsections that are bounded by the #if, #else, #elif and #endif directives are considered as separate code chunks;


Rule MC2.19.2

Summary

Non-standard characters should not occur in header file names in #include directives. (See page 83 of MISRA-C-2004 [62] , page 21 of MISRA-C-2004-TC1 [63] .)

Description

To avoid the reporting of \ in file path names, the path_uses_backslash service configuration should be used (see page 21 of MISRA-C:2004 TC1 [63] which states: “Use of the \ is permitted in filename paths if required by the host operating system of the development environment.”).

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MC2.19.2,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MC2.19.2,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MC2.19.3

Summary

The #include directive shall be followed by either a <filename> or "filename" sequence. (See page 84 of MISRA-C-2004 [62] , page 21 of MISRA-C-2004-TC1 [63] .)

Description

The reports can be tagged using the include_name_exception.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MC2.19.3,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MC2.19.3,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MC2.19.4

Summary

C macros shall only expand to a braced initialiser, a constant, a string literal, a parenthesised expression, a type qualifier, a storage class specifier, or a do-while-zero construct. (See page 84 of MISRA-C-2004 [62] , page 22 of MISRA-C-2004-TC1 [63] .)

Description

Notes:

  • it is the macro body and not the full expansion that is relevant but the preprocessed sources are also used so that the full expansion can be checked. See the MISRA forum thread “Rule 19.4 -TC1 example incorrect?”.

  • A macro with an empty body is compliant. See the MISRA forum thread “Examples”.

  • For the do-while-zero construct, there must be no semicolon at the end of the macro body.

  • Macros in header files that are used for include guards are compliant.

  • Macro bodies that are macros, identifiers or function calls are compliant (see the MISRA forum thread “macro contains unaceptable items misra c 2004 19.4”).

  • Macro bodies that just stringify (to build a string literal) or concatenate (to build an identifier) are compliant.

Configuration

See generic service options.

Option macros
macros
-config=MC2.19.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.19.5

Summary

Macros shall not be #define‘d or #undef‘d within a block. (See page 85 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option macros
macros
-config=MC2.19.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.19.6

Summary

#undef shall not be used. (See page 85 of MISRA-C-2004 [62] .)

Description

Note that, for this service, the report category is the directive name undef.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MC2.19.6,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=MC2.19.6,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=MC2.19.6,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MC2.19.7

Summary

A function should be used in preference to a function-like macro. (See page 85 of MISRA-C-2004 [62] .)

Description

Note that a macro invocation is considered to be replaceable if all the following hold:

  • all of the the macro’s parameters occur in the macro body

  • the macro body’s text does not contain special tokens (e.g. __LINE__, __FILE__, __COUNTER_, #, ##);

  • the macro is not a system macro;

  • each of the macro invocation arguments is expanded to an expression that can be interpreted as an rvalue (and hence can be used as a function call argument);

  • the macro invocation is in a context that is supported by the standard for including function calls;

  • the macro is not used to emulate a template in C;

  • the macro does not expand a non-replaceable macro.

Imprecision

False positives are reported when criteria have not been precisely determined.

Criteria such as the trade-off between code size and execution speed are not considered.

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=MC2.19.7,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=MC2.19.7,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=MC2.19.7,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.19.8

Summary

A function-like macro shall not be invoked without all of its arguments. (See page 85 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Rule MC2.19.9

Summary

Arguments to a function-like macro shall not contain tokens that look like preprocessing directives. (See page 85 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option macros
macros
-config=MC2.19.9,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.19.10

Summary

In the definition of a function-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of # or ##. (See page 85 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Option param_parentheses
param_parentheses
-config=MC2.19.10,param_parentheses=CONDS,...

Specify conditions when parameter parentheses are not required.

The configuration’s content is a short-circuit sequence of macro parameter parentheses.

CONDS:

conditions for parameter parentheses. Accepted forms are:

  • binary_op(): the parameter is an argument to a binary operator

  • unary_op(): the parameter is an argument to a unary operator

  • conditional_op(): the parameter is an argument to a conditional operator

  • pre(PRE_POST_EXPR): the tokens before the parameter must match PRE_POST_EXPR

  • post(PRE_POST_EXPR): the tokens after the parameter must match PRE_POST_EXPR

  • pre_post(PRE_POST_EXPR0,PRE_POST_EXPR1): the tokens before the parameter must match PRE_POST_EXPR0 and the tokens after the parameter must match PRE_POST_EXPR1

PRE_POST_EXPR

accepted forms are:

  • QSTRING: quoted token sequence

  • QSTRING||PRE_POST_EXPR: alternative quoted token sequences

Default:

-config=MC2.19.10,param_parentheses="pre('->'||'.')"

Option macros
macros
-config=MC2.19.10,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.19.11

Summary

All macro identifiers in preprocessor directives shall be defined before use, except in #ifdef and #ifndef preprocessor directives and the defined() operator. (See page 86 of MISRA-C-2004 [62] .)

Configuration

See generic service options.

Rule MC2.19.12

Summary

There shall be at most one occurrence of the # or ## preprocessor operators in a single macro definition. (See page 86 of MISRA-C-2004 [62] , page 22 of MISRA-C-2004-TC1 [63] .)

Configuration

See generic service options.

Option macros
macros
-config=MC2.19.12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.19.13

Summary

The # and ## preprocessor operators should not be used. (See page 86 of MISRA-C-2004 [62] , page 23 of MISRA-C-2004-TC1 [63] .)

Configuration

See generic service options.

Option macros
macros
-config=MC2.19.13,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.19.14

Summary

The defined preprocessor operator shall only be used in one of the two standard forms. (See page 87 of MISRA-C-2004 [62] .)

Description

Note also that the defined token must not be generated by macro expansion during the expansion of a #if or #elif directive.

Configuration

See generic service options.

Rule MC2.19.15

Summary

Precautions shall be taken in order to prevent the contents of a header file being included twice. (See page 87 of MISRA-C-2004 [62] .)

Description

Note that this applies to any included file regardless of the file name extension (see the definition of header file; in Appendix J, page 232 of MISRA C:2012 [45] ).

Such a file must use one of the mechanisms: ifndef and ifdef where these are defined by:

  • ifndef

#ifndef Guard_Id
#define Guard_Id ...
...
#else /* Optional */
...
#endif
#if !defined Guard_Id
#define Guard_Id ...
...
#else /* Optional */
...
#endif
  • ifdef

#ifdef Guard_Id
...
#else
#define Guard_Id ...
...
#endif
#if defined Guard_Id
...
#else
#define Guard_Id ...
...
#endif

Note that the guard name Guard_Id must be unique for each file in the project.

With the guard service configuration, it can also be specified that:

  • the guard’s macro name matches a specified derived form of the file name,

  • whether there should be a comment containing the guard’s macro name following the closing #endif, and

  • whether the macro name may be reused elsewhere in the source code.

Note that the guard service configuration can be used to change the guard mechanism.

Configuration

See generic service options.

Option guard
guard
-config=MC2.19.15,guard={FILE, {CHECK,...}},...

Specify the allowed mechanisms to prevent the contents of a header file being included twice using advanced features.

The configuration’s content is an ordered list of file selectors with conditions; the conditions in the first clause whose file selector matches the file are checked.

FILE:

a -file_tag identifier or a matcher expression used to select the files.

CHECK

Accepted forms are:

  • mechanism(MECHANISM[||MECHANISM]*): the guard’s mechanism

  • guard(GUARD): the file name replacer REPLACER (see the -replacer global configuration). The input provided to the replacer is the canonical pathname of the guarded file; the macro name must match exactly, or must match the regular expression defined by FMT

  • comment(COMMENT_MATCHER): it will be reported if there is no matching comment following the #endif

  • reuse(REUSE_TAG): tag indicating if what reuse of the macro name should be reported

  • regex(): the replaced name is a regular expression that must match the macro guard name

REUSE_TAG

accepted forms are:

  • all_code: it is reported if the same guard identifier is reused for an identifier anywhere in the project code

  • all_defined: it is reported if the same guard identifier is redefined or undefined anywhere in the project

  • all_guards_in_unit: it is reported if the same guard identifier is used for more than one header file in the translation unit

  • all_guards_in_project: it is reported if the same guard identifier is used for more than one header file in the project

MECHANISM

accepted forms are:

  • any: any mechanism

  • ifndef: the guard mechanism using #ifndef Guard_Id or if !defined Guard_Id

  • ifdef: the mechanism using #if defined Guard_Id

  • pragma: the mechanism #pragma once

Default:

-config=MC2.19.15,guard={^.*$, {"mechanism(ifndef||ifdef)", "guard(__base_name_upcase_id_repl($0,'M'))", "reuse(all_defined)"}}

Option directives
directives
-config=MC2.19.15,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MC2.19.16

Summary

Preprocessing directives shall be syntactically meaningful even when excluded by the preprocessor. (See page 88 of MISRA-C-2004 [62] .)

Description

The service will report a preprocessing directive if:

  • it is a conditional directive that does not follow the pattern specified in Section 6.8 in the C90 standard [34];

  • it is an #else or #endif directive that is not followed by a whitespace.

Note also that any parsing errors in the preprocessing code that are not excluded by conditional compilation will be reported by the service B.PARSER.

This service depends upon the configuration of the following ancillary services: STD.prepdirc

Configuration

See generic service options.

Option behaviors
behaviors
-config=MC2.19.16,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MC2.19.17

Summary

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if or #ifdef directive to which they are related. (See page 88 of MISRA-C-2004 [62] .)

Description

Note that non-compliant preprocessor conditional constructs will be reported by the ECLAIR rule B.PARSER.

Configuration

See generic service options.

Rule MC2.20.1

Summary

Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined. (See page 89 of MISRA-C-2004 [62] , page 23 of MISRA-C-2004-TC1 [63] .)

Description

The reserved identifiers are defined to include all the following:

  • identifiers that are reserved by the C90 standard [34];

  • identifiers that are reserved by the standard used by the translation unit;

  • identifiers that are reserved for future library directions (see MISRA exemplar suite for Rule 20.1).

The default configuration checks identifiers that are reserved by the standard library; to specify that identifiers provided by the project standard library posix are also reserved, use the -stdlib global configuration with the reserved_standard service configuration. For example, with the configuration lines:

-+stdlib=posix
-config=MC2.20.1,reserved_standard+="posix"

the reserved identifiers in the posix library will be checked.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+={my_lib, c, 2022, c, "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)", "file_scope"}

Then with the service configuration line

-config=MC2.20.1,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC2.20.1,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC2.20.1,reserved_standard="std()"

Option macros
macros
-config=MC2.20.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=MC2.20.1,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.20.2

Summary

The names of standard library macros, objects and functions shall not be reused. (See page 90 of MISRA-C-2004 [62] .)

Description

The reserved identifiers are defined to include all the following:

  • identifiers that are reserved by the C90 standard [34];

  • identifiers that are reserved by the standard used by the translation unit;

  • identifiers reserved for future library directions (see the MISRA forum thread “20.1, 20.2 scopes”).

If the compiler language is C++, then namespace and tag qualifiers are considered relevant.

Note that MISRA Rule 2.2 is only for non-preprocessor identifiers such as objects, function names and typedefs (see the MISRA forum thread “MISRA Rule 20.1 and 20.2”).

The default configuration checks identifiers that are reserved by the standard library; to specify that identifiers provided by the project standard library posix are also reserved, use the -stdlib global configuration with the reserved_standard service configuration. For example, with the configuration lines:

-+stdlib=posix
-config=MC2.20.2,reserved_standard+="posix"

the reserved identifiers in the posix library will be checked.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+={my_lib, c, 2022, c, "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)", "file_scope"}

Then with the service configuration line

-config=MC2.20.2,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MC2.20.2,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MC2.20.2,reserved_standard="std()"

Option declarations
declarations
-config=MC2.20.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.20.3

Summary

The validity of values passed to library functions shall be checked. (See page 90 of MISRA-C-2004 [62] , page 24 of MISRA-C-2004-TC1 [63] .)

Implementation

Reports if specified arguments of calls to the standard library functions have not been validated.

An argument is taken to be validated if it is a constant expression or it is a variable and:

  • it occurs in an assertion prior to the function call in the context of a selection, iteration or block node;

  • the call is in a then or else branch of an if statement or the body of a while or for statement and the variable occurs in the condition part;

  • as in the previous case, but in a conditional operator expression.

Constant expressions are validated against the function’s requirements.

Imprecision

False negatives are present because not all functions’ requirements are checked.

Configuration

See generic service options.

Rule MC2.20.4

Summary

Dynamic heap memory allocation shall not be used. (See page 91 of MISRA-C-2004 [62] .)

Description

The service reports:

  • Any use of a function that has the malloc property. That is if the function:

    • has the attribute malloc; or

    • it is one of the standard library functions malloc, calloc, realloc, free, strdup, operator new and operator delete.

  • Any use of a standard library container class that has a type whose a template type argument is an instance of std::allocator.

Additional functions can be assigned the property malloc using the -call_properties global configuration. For example, the following configuration declares that any function whose identifier has the suffix _m has the property malloc:

-call_properties+={"decl(^.*_m\\(.*$)", {malloc}}

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=MC2.20.4,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=MC2.20.4,extra_statements={}

Option statements
statements
-config=MC2.20.4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MC2.20.4,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MC2.20.5

Summary

The error indicator errno shall not be used. (See page 91 of MISRA-C-2004 [62] .)

Description

There must be no use of the macro errno defined in errno.h or of the function perrno() declared in stdio.h.

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC2.20.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC2.20.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.20.6

Summary

The macro offsetof, in library <stddef.h>, shall not be used. (See page 91 of MISRA-C-2004 [62] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.20.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC2.20.6,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.20.7

Summary

The setjmp macro and the longjmp function shall not be used. (See page 92 of MISRA-C-2004 [62] .)

Description

There must be no use of the macro setjmp defined in setjmp.h and the function longjmp declared in setjmp.h.

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.20.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC2.20.7,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.20.8

Summary

The signal handling facilities of <signal.h> shall not be used. (See page 92 of MISRA-C-2004 [62] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.20.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC2.20.8,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.20.9

Summary

The input/output library <stdio.h> shall not be used in production code. (See page 92 of MISRA-C-2004 [62] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.20.9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC2.20.9,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.20.10

Summary

The library functions atof, atoi and atol from library <stdlib.h> shall not be used. (See page 92 of MISRA-C-2004 [62] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.20.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.20.11

Summary

The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used. (See page 92 of MISRA-C-2004 [62] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MC2.20.11,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MC2.20.11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MC2.20.12

Summary

The time handling functions of library <time.h> shall not be used. (See page 92 of MISRA-C-2004 [62] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MC2.20.12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MC2.20.12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MC2.21.1

Summary

Minimisation of run-time failures shall be ensured by the use of at least one of:

  1. static analysis tools/techniques;

  2. dynamic analysis tools/techniques;

  3. explicit coding of checks to handle run-time faults.

(See page 93 of MISRA-C-2004 [62] .)

Description

The document service configuration should be used to specify, for each unexpected behavior kind, where the documenting comment will be found and the expected format.

The behavior kinds that are checked for documentation are:

  • overflow,

  • unexpected wrapping,

  • invalid shift,

  • division/remainder by zero,

  • unsequenced side effects,

  • read from uninitialized automatic object,

  • read from uninitialized allocated object,

  • write to string literal or const object,

  • non-volatile access to volatile object,

  • access to dead allocated object,

  • access to dead automatic object,

  • access to dead thread object,

  • access using null pointer,

  • access using invalid pointer,

  • access using out-of-bounds pointer,

  • access using unaligned pointer,

  • mistyped access to object,

  • mistyped access to function,

  • invalid pointer arithmetic,

  • invalid pointer comparison,

  • overlapping copy,

  • invalid arguments to function,

  • returned function error,

  • tainted input,

  • data race,

  • invariant violation,

  • communication error.

Using the default value for document valid documentation comments look like:

/* Documentation for MISRA-C:2004 Rule 21.1: overflow ... To Be Written ... */
/* Documentation for MISRA-C:2004 Rule 21.1: unexpected wrapping ... To Be Written ... */
/* Documentation for MISRA-C:2004 Rule 21.1: invalid shift ... To Be Written ... */
/* ... */
/* Documentation for MISRA-C:2004 Rule 21.1: communication error ... To Be Written ... */

These special comments should be placed in a compiled file, otherwise, ECLAIR will not be able to detect them. For each of them the ... To Be Written ... should be replaced with the description of what is done to minimize the risk or why the situation cannot happen or is not relevant for the project.

Configuration

See generic service options.

Option document
document
-config=MC2.21.1,document={ID_FMT, SUB, FILE_MATCHER, WHAT, DOC_FMT, REP_FMT},...

Specify how to extrapolate the required documentation from comments in the specified compiled source files.

The configuration’s content is a list of tuples that provide (in order) a unique identifier for the document, context and file matcher indicating where to search for the document, what to check for (e.g., missing documentation), a format for matcher to check the documentation content and a format for the reports.

ID_FMT:

format (see the -fmt global configuration content, template userdocs__id_default_fmt) for short but unique name to identify the document with field:

service

service name.

SUB:

tag indicating subject. Accepted values are:

  • unit: check all files for each translation unit;

  • file: check each file;

  • program: check all the program files;

  • project: check all the project files;

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

WHAT:

tag indicating what to report. Accepted values are:

  • duplicates: report if more than one matching document is found;

  • missing: report if no documentation is found;

  • missing_if_noted: report if no documentation is found and uses are noted;

  • all: report any duplicated or missing documentation;

  • none: do not report missing or duplicated documentation;

DOC_FMT:

format (see the -fmt global configuration content, template userdocs__document_default_fmt) specifying regular expression to match the document content with fields:

document_id

a document identifier;

file

canonical pathname;

rule

rule description;

service

service name.

REP_FMT:

format (see the -fmt global configuration content, template userdocs__default_fmt) for message to be included in the report with fields:

document_id

a document identifier;

file

canonical pathname;

error

message indicating the error kind which can be missing_file, missing_docs or duplicate_docs;

target

unit, program or project description;

service

service name.

Default:

-config=MC2.21.1,document={"%{__overflow_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__wrapping_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__shift_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__division_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__side_effects_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__write_to_const_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__non_volatile_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_thread_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__null_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__bounds_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__unaligned_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_object_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_function_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_arith_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_compare_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__overlap_copy_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_fun_args_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__return_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__tainted_input_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__data_race_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invariant_viol_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__comms_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"}

Option ignored_comments
ignored_comments
-config=MC2.21.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


MISRA-C:2004 Coding Standard Coverage

This section presents a table with a concise summary of the coverage provided by this version of ECLAIR for the MISRA C:2004 coding standard [62].

For all guidelines, the mapping between the MISRA C:2004 rules and the ECLAIR service identifiers is one-to-one and straightforward. e.g., MISRA C:2004 Rule 1.2 maps to ECLAIR service MC2.1.2

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MC2 synopsis: supported MISRA-C:2004 rules

Id

Summary

Precision

MC2.1.1

All code shall conform to ISO 9899:1990 “Programming languages - C”, amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2:1996

Complete

MC2.1.2

No reliance shall be placed on undefined or unspecified behaviour

Best-effort

MC2.1.3

Multiple compilers and/or languages shall only be used if there is a common defined interface standard for object code to which the languages/compilers/assemblers conform

Process

MC2.1.4

The compiler/linker shall be checked to ensure that 31 character significance and case sensitivity are supported for external identifiers

Exact

MC2.1.5

Floating-point implementations should comply with a defined floating-point standard

Process

MC2.2.1

Assembly language shall be encapsulated and isolated

Exact

MC2.2.2

Source code shall only use /* ... */ style comments

Exact

MC2.2.3

The character sequence /* shall not be used within a comment

Exact

MC2.2.4

Sections of code should not be “commented out”

Heuristic

MC2.3.1

All usage of implementation-defined behaviour shall be documented

Process

MC2.3.2

The character set and the corresponding encoding shall be documented

Process

MC2.3.3

The implementation of integer division in the chosen compiler should be determined, documented and taken into account

Process

MC2.3.4

All uses of the #pragma directive shall be documented and explained

Process

MC2.3.5

If it is being relied upon, the implementation-defined behaviour and packing of bitfields shall be documented

Process

MC2.3.6

All libraries used in production code shall be written to comply with the provisions of this document, and shall have been subject to appropriate validation

Exact

MC2.4.1

Only those escape sequences that are defined in the ISO C standard shall be used

Exact

MC2.4.2

Trigraphs shall not be used

Exact

MC2.5.1

Identifiers (internal and external) shall not rely on the significance of more than 31 characters

Exact

MC2.5.2

Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier

Exact

MC2.5.3

A typedef name shall be a unique identifier

Exact

MC2.5.4

A tag name shall be a unique identifier

Exact

MC2.5.5

No object or function identifier with static storage duration should be reused

Exact

MC2.5.6

No identifier in one name space should have the same spelling as an identifier in another name space, with the exception of structure member and union member names

Exact

MC2.5.7

No identifier name should be reused

Exact

MC2.6.1

The plain char type shall be used only for the storage and use of character values

Exact

MC2.6.2

signed and unsigned char type shall be used only for the storage and use of numeric values

Exact

MC2.6.3

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MC2.6.4

Bit fields shall only be defined to be of type unsigned int or signed int

Exact

MC2.6.5

Bit fields of signed type shall be at least 2 bits long

Exact

MC2.7.1

Octal constants (other than zero) and octal escape sequences shall not be used

Exact

MC2.8.1

Functions shall have prototype declarations and the prototype shall be visible at both the function definition and call

Exact

MC2.8.2

Whenever an object or function is declared or defined, its type shall be explicitly stated

Exact

MC2.8.3

For each function parameter the type given in the declaration and definition shall be identical, and the return types shall also be identical

Exact

MC2.8.4

If objects or functions are declared more than once their types shall be compatible

Exact

MC2.8.5

There shall be no definitions of objects or functions in a header file

Exact

MC2.8.6

Functions shall be declared at file scope

Exact

MC2.8.7

Objects shall be defined at block scope if they are only accessed from within a single function

Exact

MC2.8.8

An external object or function shall be declared in one and only one file

Exact

MC2.8.9

An identifier with external linkage shall have exactly one external definition

Exact

MC2.8.10

All declarations and definitions of objects or functions at file scope shall have internal linkage unless external linkage is required

Exact

MC2.8.11

The static storage class specifier shall be used in definitions and declarations of objects and functions that have internal linkage

Exact

MC2.8.12

When an array is declared with external linkage, its size shall be stated explicitly or defined implicitly by initialisation

Exact

MC2.9.1

All automatic variables shall have been assigned a value before being used

Complete

MC2.9.2

Braces shall be used to indicate and match the structure in the non-zero initialisation of arrays and structures

Exact

MC2.9.3

In an enumerator list, the = construct shall not be used to explicitly initialise members other than the first, unless all items are explicitly initialised

Exact

MC2.10.1

The value of an expression of integer type shall not be implicitly converted to a different underlying type if:

  1. it is not a conversion to a wider integer type of the same signedness, or

  2. the expression is complex, or

  3. the expression is not constant and is a function argument, or

  4. the expression is not constant and is a return expression.

Exact

MC2.10.2

The value of an expression of floating type shall not be implicitly converted to a different type if:

  1. it is not a conversion to a wider floating type, or

  2. the expression is complex, or

  3. the expression is a function argument, or

  4. the expression is a return expression.

Exact

MC2.10.3

The value of a complex expression of integer type shall only be cast to a type of the same signedness that is no wider than the underlying type of the expression

Exact

MC2.10.4

The value of a complex expression of floating type shall only be cast to a floating type which is narrower or of the same size

Exact

MC2.10.5

If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

Exact

MC2.10.6

A U suffix shall be applied to all constants of unsigned type

Exact

MC2.11.1

Conversions shall not be performed between a pointer to a function and any type other than an integral type

Exact

MC2.11.2

Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object type or a pointer to void

Exact

MC2.11.3

A cast should not be performed between a pointer type and an integral type

Exact

MC2.11.4

A cast should not be performed between a pointer to object type and a different pointer to object type

Exact

MC2.11.5

A cast shall not be performed that removes any const or volatile qualification from the type addressed by a pointer

Exact

MC2.12.1

Limited dependence should be placed on C’s operator precedence rules in expressions

Exact

MC2.12.2

The value of an expression shall be the same under any order of evaluation that the standard permits

Safe

MC2.12.3

The sizeof operator shall not be used on expressions that contain side effects

Exact

MC2.12.4

The right-hand operand of a logical && or || operator shall not contain side effects

Safe

MC2.12.5

The operands of a logical && or || shall be primary-expressions

Exact

MC2.12.6

The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, != and ?:)

Exact

MC2.12.6L

The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, != and ?:)

Exact

MC2.12.7

Bitwise operators shall not be applied to operands whose underlying type is signed

Exact

MC2.12.8

The right-hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left-hand operand

Complete

MC2.12.9

The unary minus operator shall not be applied to an expression whose underlying type is unsigned

Exact

MC2.12.10

The comma operator shall not be used

Exact

MC2.12.11

Evaluation of constant unsigned integer expressions should not lead to wrap-around

Exact

MC2.12.12

The underlying bit representations of floating-point values shall not be used

Complete

MC2.12.13

The increment (++) and decrement (--) operators should not be mixed with other operators in an expression

Exact

MC2.13.1

Assignment operators shall not be used in expressions that yield a Boolean value

Exact

MC2.13.2

Tests of a value against zero should be made explicit, unless the operand is effectively Boolean

Exact

MC2.13.3

Floating-point expressions shall not be tested for equality or inequality

Best-effort

MC2.13.4

The controlling expression of a for statement shall not contain any objects of floating type

Exact

MC2.13.5

The three expressions of a for statement shall be concerned only with loop control

Complete

MC2.13.5S

The three expressions of a for statement shall be concerned only with loop control

Complete

MC2.13.6

Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop

Complete

MC2.13.7

Boolean operations whose results are invariant shall not be permitted

Best-effort

MC2.14.1

There shall be no unreachable code

Best-effort

MC2.14.2

All non-null statements shall either:

  1. have at least one side-effect however executed, or

  2. cause control flow to change.

Complete

MC2.14.3

Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment provided that the first character following the null statement is a white-space character

Exact

MC2.14.4

The goto statement shall not be used

Exact

MC2.14.5

The continue statement shall not be used

Exact

MC2.14.6

For any iteration statement there shall be at most one break statement used for loop termination

Exact

MC2.14.7

A function shall have a single point of exit at the end of the function

Exact

MC2.14.8

The statement forming the body of a switch, while, dowhile or for statement shall be a compound statement

Exact

MC2.14.9

An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement

Exact

MC2.14.10

All if ... else if constructs shall be terminated with an else clause

Exact

MC2.15.0

The preamble normative text in section 15 shall be treated as Rule 15.0. Any deviation from the normative text shall be considered a non-compliance if no other rule in section 15 is not complied with

Exact

MC2.15.1

A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MC2.15.2

An unconditional break statement shall terminate every non-empty switch clause

Exact

MC2.15.3

The final clause of a switch statement shall be the default clause

Exact

MC2.15.4

A switch expression shall not represent a value that is effectively Boolean

Exact

MC2.15.5

Every switch statement shall have at least one case clause

Exact

MC2.16.1

Functions shall not be defined with a variable number of arguments

Exact

MC2.16.2

Functions shall not call themselves, either directly or indirectly

Complete

MC2.16.3

Identifiers shall be given for all of the parameters in a function prototype declaration

Exact

MC2.16.4

The identifiers used in the declaration and definition of a function shall be identical

Exact

MC2.16.5

Functions with no parameters shall be declared and defined with parameter type void

Exact

MC2.16.6

The number of arguments passed to a function shall match the number of parameters

Exact

MC2.16.7

A pointer parameter in a function prototype should be declared as pointer to const if the pointer is not used to modify the addressed object

Best-effort

MC2.16.8

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MC2.16.9

A function identifier shall only be used with either a preceding &, or with a parenthesised parameter list, which may be empty

Exact

MC2.16.10

If a function returns error information, then that error information shall be tested

Process

MC2.17.1

Pointer arithmetic shall only be applied to pointers that address an array or array element

Complete

MC2.17.2

Pointer subtraction shall only be applied to pointers that address elements of the same array

Complete

MC2.17.3

>, >=, <, <= shall not be applied to pointer types except where they point to the same array

Complete

MC2.17.4

Array indexing shall be the only allowed form of pointer arithmetic

Exact

MC2.17.5

The declaration of objects should contain no more than 2 levels of pointer indirection

Exact

MC2.17.6

The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist

Safe

MC2.18.1

All structure and union types shall be complete at the end of a translation unit

Exact

MC2.18.2

An object shall not be assigned to an overlapping object

Best-effort

MC2.18.3

An area of memory shall not be reused for unrelated purposes

Process

MC2.18.4

Unions shall not be used

Exact

MC2.19.1

#include statements in a file should only be preceded by other preprocessor directives or comments

Exact

MC2.19.2

Non-standard characters should not occur in header file names in #include directives

Exact

MC2.19.3

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MC2.19.4

C macros shall only expand to a braced initialiser, a constant, a string literal, a parenthesised expression, a type qualifier, a storage class specifier, or a do-while-zero construct

Exact

MC2.19.5

Macros shall not be #define‘d or #undef‘d within a block

Exact

MC2.19.6

#undef shall not be used

Exact

MC2.19.7

A function should be used in preference to a function-like macro

Complete

MC2.19.8

A function-like macro shall not be invoked without all of its arguments

Exact

MC2.19.9

Arguments to a function-like macro shall not contain tokens that look like preprocessing directives

Exact

MC2.19.10

In the definition of a function-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of # or ##

Exact

MC2.19.11

All macro identifiers in preprocessor directives shall be defined before use, except in #ifdef and #ifndef preprocessor directives and the defined() operator

Exact

MC2.19.12

There shall be at most one occurrence of the # or ## preprocessor operators in a single macro definition

Exact

MC2.19.13

The # and ## preprocessor operators should not be used

Exact

MC2.19.14

The defined preprocessor operator shall only be used in one of the two standard forms

Exact

MC2.19.15

Precautions shall be taken in order to prevent the contents of a header file being included twice

Exact

MC2.19.16

Preprocessing directives shall be syntactically meaningful even when excluded by the preprocessor

Exact

MC2.19.17

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if or #ifdef directive to which they are related

Exact

MC2.20.1

Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined

Exact

MC2.20.2

The names of standard library macros, objects and functions shall not be reused

Exact

MC2.20.3

The validity of values passed to library functions shall be checked

Best-effort

MC2.20.4

Dynamic heap memory allocation shall not be used

Exact

MC2.20.5

The error indicator errno shall not be used

Exact

MC2.20.6

The macro offsetof, in library <stddef.h>, shall not be used

Exact

MC2.20.7

The setjmp macro and the longjmp function shall not be used

Exact

MC2.20.8

The signal handling facilities of <signal.h> shall not be used

Exact

MC2.20.9

The input/output library <stdio.h> shall not be used in production code

Exact

MC2.20.10

The library functions atof, atoi and atol from library <stdlib.h> shall not be used

Exact

MC2.20.11

The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used

Exact

MC2.20.12

The time handling functions of library <time.h> shall not be used

Exact

MC2.21.1

Minimisation of run-time failures shall be ensured by the use of at least one of:

  1. static analysis tools/techniques;

  2. dynamic analysis tools/techniques;

  3. explicit coding of checks to handle run-time faults.

Process

MISRA C:2004 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C:2004 coding standard [62].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C:2004 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

1.1
Required

no violation report or caution report for MC2.1.1

1.2
Required

no violation report for MC2.1.2

after:

1.3
Required

no violation report for MC2.1.3

before: check the interface standards for each compiler and/or language used by the source files and white-list using the compilers service configuration.

1.4
Required

no violation report for MC2.1.4

1.5
Advisory

no violation report for MC2.1.5

after: content of documentation

2.1
Required

no violation report for MC2.2.1

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

2.2
Required

no violation report for MC2.2.2

2.3
Required

no violation report for MC2.2.3

2.4
Advisory

no violation report for MC2.2.4

after: unreported comments that may contain unrecognised code

3.1
Required

no violation report for MC2.3.1

after: content of the documentation

3.2
Required

no violation report or caution report for MC2.3.2

before: document each source, execution character set and the corresponding encoding using the behavior configuration of the related ancillary services

3.3
Advisory

no violation report for MC2.3.3

before: document the expected direction of rounding using the behavior configuration of the related ancillary services

3.4
Required

no violation report for MC2.3.4

before: document each #pragma directive in the non-skipped compiled file contents using the behavior configuration of the related ancillary services

3.5
Required

no violation report for MC2.3.5

before: document each class, struct or union that contains a bit-field using the behavior configuration of the related ancillary services

3.6
Required

no violation report for MC2.3.6

4.1
Required

no violation report for MC2.4.1

4.2
Required

no violation report for MC2.4.2

5.1
Required

no violation report for MC2.5.1

5.2
Required

no violation report for MC2.5.2

5.3
Required

no violation report for MC2.5.3

5.4
Required

no violation report for MC2.5.4

5.5
Advisory

no violation report for MC2.5.5

5.6
Advisory

no violation report for MC2.5.6

5.7
Advisory

no violation report for MC2.5.7

6.1
Required

no violation report for MC2.6.1

6.2
Required

no violation report for MC2.6.2

6.3
Advisory

no violation report for MC2.6.3

6.4
Required

no violation report for MC2.6.4

6.5
Required

no violation report for MC2.6.5

7.1
Required

no violation report for MC2.7.1

8.1
Required

no violation report for MC2.8.1

8.2
Required

no violation report for MC2.8.2

8.3
Required

no violation report for MC2.8.3

8.4
Required

no violation report for MC2.8.4

8.5
Required

no violation report for MC2.8.5

8.6
Required

no violation report for MC2.8.6

8.7
Required

no violation report for MC2.8.7

8.8
Required

no violation report for MC2.8.8

8.9
Required

no violation report for MC2.8.9

8.10
Required

no violation report for MC2.8.10

8.11
Required

no violation report for MC2.8.11

8.12
Required

no violation report for MC2.8.12

9.1
Required

no caution or violation for this rule and rule 14.4

9.2
Required

no violation report for MC2.9.2

9.3
Required

no violation report for MC2.9.3

10.1
Required

no violation report for MC2.10.1

10.2
Required

no violation report for MC2.10.2

10.3
Required

no violation report for MC2.10.3

10.4
Required

no violation report for MC2.10.4

10.5
Required

no violation report for MC2.10.5

10.6
Required

no violation report for MC2.10.6

11.1
Required

no violation report for MC2.11.1

11.2
Required

no violation report for MC2.11.2

11.3
Advisory

no violation report for MC2.11.3

11.4
Advisory

no violation report for MC2.11.4

11.5
Required

no violation report for MC2.11.5

12.1
Advisory

no violation report for MC2.12.1

12.2
Required

no violation report or caution report for MC2.12.2

12.3
Required

no violation report for MC2.12.3

12.4
Required

no violation report or caution report for MC2.12.4

12.5
Required

no violation report for MC2.12.5

12.6
Advisory

no violation report for MC2.12.6

12.7
Required

no violation report for MC2.12.7

12.8
Required

no violation report or caution report for MC2.12.8

12.9
Required

no violation report for MC2.12.9

12.10
Required

no violation report for MC2.12.10

12.11
Advisory

no violation report for MC2.12.11

12.12
Required

no violation report for MC2.12.12

12.13
Advisory

no violation report for MC2.12.13

13.1
Required

no violation report for MC2.13.1

13.2
Advisory

no violation report for MC2.13.2

13.3
Required

no violation report for MC2.13.3

after: conduct a manual review of every equality or disequality test that could indirectly involve floating-point values

13.4
Required

no violation report for MC2.13.4

13.5
Required

no violation report or caution report for MC2.13.5

13.6
Required

no violation report or caution report for MC2.13.6

13.7
Required

no violation report for MC2.13.7

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

14.1
Required

no violation report for MC2.14.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

14.2
Required

no violation report for MC2.14.2

14.3
Required

no violation report for MC2.14.3

14.4
Required

no violation report for MC2.14.4

14.5
Required

no violation report for MC2.14.5

14.6
Required

no violation report for MC2.14.6

14.7
Required

no violation report for MC2.14.7

14.8
Required

no violation report for MC2.14.8

14.9
Required

no violation report for MC2.14.9

14.10
Required

no violation report for MC2.14.10

after: check the content of any explanatory comment

15.0
Required

no violation report for MC2.15.0

15.1
Required

no violation report for MC2.15.1

15.2
Required

no violation report for MC2.15.2

15.3
Required

no violation report for MC2.15.3

after: content of replacement comment

15.4
Required

no violation report for MC2.15.4

15.5
Required

no violation report for MC2.15.5

16.1
Required

no violation report for MC2.16.1

16.2
Required

no violation report or caution report for MC2.16.2

16.3
Required

no violation report for MC2.16.3

16.4
Required

no violation report for MC2.16.4

16.5
Required

no violation report for MC2.16.5

16.6
Required

no violation report for MC2.16.6

16.7
Advisory

no violation report for MC2.16.7

after: check each non-const pointer with program scope for compliance

16.8
Required

no violation report for MC2.16.8

16.9
Required

no violation report for MC2.16.9

16.10
Required

no violation report for MC2.16.10

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

17.1
Required

no violation report or caution report for MC2.17.1

17.2
Required

no violation report or caution report for MC2.17.2

17.3
Required

no violation report or caution report for MC2.17.3

17.4
Required

no violation report for MC2.17.4

17.5
Advisory

no violation report for MC2.17.5

17.6
Required

no violation report or caution report for MC2.17.6

18.1
Required

no violation report for MC2.18.1

18.2
Required

no violation report for MC2.18.2

after: assignments to or from objects created with some overlap in memory with another object should be checked

18.3
Required

no violation report for MC2.18.3

before: document in the source code if and how an area of memory may be reused for unrelated data; specify using the document service configuration the position and format of the document;
after: content of documentation

18.4
Required

no violation report for MC2.18.4

19.1
Advisory

no violation report for MC2.19.1

19.2
Advisory

no violation report for MC2.19.2

19.3
Required

no violation report for MC2.19.3

19.4
Required

no violation report for MC2.19.4

19.5
Required

no violation report for MC2.19.5

19.6
Required

no violation report for MC2.19.6

19.7
Advisory

no violation report for MC2.19.7

19.8
Required

no violation report for MC2.19.8

19.9
Required

no violation report for MC2.19.9

19.10
Required

no violation report for MC2.19.10

19.11
Required

no violation report for MC2.19.11

19.12
Required

no violation report for MC2.19.12

19.13
Advisory

no violation report for MC2.19.13

19.14
Required

no violation report for MC2.19.14

19.15
Required

no violation report for MC2.19.15

19.16
Required

no violation report for MC2.19.16

19.17
Required

no violation report for MC2.19.17

20.1
Required

no violation report for MC2.20.1

20.2
Required

no violation report for MC2.20.2

20.3
Required

no violation report for MC2.20.3

after: ensure that the source codes’ validity checks cover the functions’ requirements

20.4
Required

no violation report for MC2.20.4

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

20.5
Required

no violation report for MC2.20.5

20.6
Required

no violation report for MC2.20.6

20.7
Required

no violation report for MC2.20.7

20.8
Required

no violation report for MC2.20.8

20.9
Required

no violation report for MC2.20.9

20.10
Required

no violation report for MC2.20.10

20.11
Required

no violation report for MC2.20.11

20.12
Required

no violation report for MC2.20.12

21.1
Required

no violation report for MC2.21.1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using the document service configuration the position and format of the document

The BUGSENG MET Services

This section contains documentation on ECLAIR services for specific metric reporting.

For each of the supported metrics, the identifier for the corresponding meter is obtained by adding the prefix MET, thereby obtaining, for example: MET.B.VOCF_FUNC, MET.HIS.GOTO, …

Note that the page numbers included in the references to the HIS Source Code Metrics [13] in the ECLAIR service summaries are for the PDF version of [13] .

Meter MET.B.ACPATH_FUNC

Summary

Report metric B.ACPATH_FUNC (number of acyclic paths through a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.ACPATH_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.ALLSTMTS_FUNC

Summary

Report metric B.ALLSTMTS_FUNC (total number of statements except block, empty statements, labels and declarations in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.ALLSTMTS_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.BLOCKNEST_FUNC

Summary

Report metric B.BLOCKNEST_FUNC (depth of nesting of blocks in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.BLOCKNEST_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.CALLER_PROG

Summary

Report metric B.CALLER_PROG (number of functions calling a function in a program).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.CALLER_PROG,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.CALL_FUNC

Summary

Report metric B.CALL_FUNC (number of direct and indirect function calls in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.CALL_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.CALL_UNIT

Summary

Report metric B.CALL_UNIT (number of direct and indirect function calls in a unit).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.CALL_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.CMNTLINE_JFUNC

Summary

Report metric B.CMNTLINE_JFUNC (number of non-empty comment lines in a function in the project).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.CMNTLINE_JFUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.COMF_JFUNC

Summary

Report metric B.COMF_JFUNC (comment density in a function in the project).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.COMF_JFUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.COMMENT_FUNC

Summary

Report metric B.COMMENT_FUNC (number of comments in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.COMMENT_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.EXID_PROG

Summary

Report metric B.EXID_PROG (number of external identifiers in a program).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.EXID_PROG,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.HARRISON_FUNC

Summary

Report metric B.HARRISON_FUNC (Harrison’s Complexity Metric).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.HARRISON_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.LINES_FILE

Summary

Report metric B.LINES_FILE (number of physical lines in a file).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.LINES_FILE,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.LINES_FUNC

Summary

Report metric B.LINES_FUNC (number of physical lines in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.LINES_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.LOGBOP_FUNC

Summary

Report metric B.LOGBOP_FUNC (number of && and || operators in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.LOGBOP_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.LSLOCS_FUNC

Summary

Report metric B.LSLOCS_FUNC (number of logical source lines of code in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.LSLOCS_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.MCCABE_FUNC

Summary

Report metric B.MCCABE_FUNC (mcCabe’s original Complexity Metric).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.MCCABE_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.NAMED_PARAM_FUNC

Summary

Report metric B.NAMED_PARAM_FUNC (number of named function parameters in a function definition).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.NAMED_PARAM_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.NOELSE_FUNC

Summary

Report metric B.NOELSE_FUNC (number of if-else-if without an else in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.NOELSE_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.NPATH_FUNC

Summary

Report metric B.NPATH_FUNC (number of npaths through a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.NPATH_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.PARAM_FUNC

Summary

Report metric B.PARAM_FUNC (number of parameters in a function definition).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.PARAM_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.RETPOINTS_FUNC

Summary

Report metric B.RETPOINTS_FUNC (number of return points in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.RETPOINTS_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STATL_FUNC

Summary

Report metric B.STATL_FUNC (number of references to local statically-allocated variables in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STATL_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STATNL_FUNC

Summary

Report metric B.STATNL_FUNC (number of references to non-local statically-allocated variables in a function).

Configuration

See generic service options.

Option metric_decimal_digits
metric_decimal_digits
-config=MET.B.STATNL_FUNC,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=MET.B.STATNL_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STBAK_FUNC

Summary

Report metric B.STBAK_FUNC (number of back jumps in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STBAK_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STCYC_FUNC

Summary

Report metric B.STCYC_FUNC (mcCabe’s Complexity Metric).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STCYC_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STFCO_UNIT

Summary

Report metric B.STFCO_UNIT (function coupling in a unit).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STFCO_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STFNC_UNIT

Summary

Report metric B.STFNC_UNIT (number of function definitions in a unit).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STFNC_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STGTO_FUNC

Summary

Report metric B.STGTO_FUNC (number of goto statements in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STGTO_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STM22_UNIT

Summary

Report metric B.STM22_UNIT (number of statement-like language constructs in a translation unit).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STM22_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STM28_UNIT

Summary

Report metric B.STM28_UNIT (number of comments in a translation unit).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STM28_UNIT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STMIF_FUNC

Summary

Report metric B.STMIF_FUNC (depth of nesting of iteration and selection statements).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STMIF_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STMT_HARRISON_FUNC

Summary

Report metric B.STMT_HARRISON_FUNC (statement-only variant of Harrison’s Complexity Metric).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STMT_HARRISON_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STRET_FUNC

Summary

Report metric B.STRET_FUNC (number of returns in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STRET_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STST1_FUNC

Summary

Report metric B.STST1_FUNC (number of statements not in a statement expression in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STST1_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STST2_FUNC

Summary

Report metric B.STST2_FUNC (number of statements except block, empty statements and labels in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STST2_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STST3_FUNC

Summary

Report metric B.STST3_FUNC (number of statements except block, empty statements, labels and declarations in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STST3_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STSUB_FUNC

Summary

Report metric B.STSUB_FUNC (number of function calls in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STSUB_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.STXLN_FUNC

Summary

Report metric B.STXLN_FUNC (number of executable lines of code in a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.B.STXLN_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.B.VOCF_FUNC

Summary

Report metric B.VOCF_FUNC (the VOCF language scope metric).

Configuration

See generic service options.

Option metric_decimal_digits
metric_decimal_digits
-config=MET.B.VOCF_FUNC,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.

Default:

-config=MET.B.VOCF_FUNC,metric_decimal_digits={B.VOCF_FUNC, 1}

Option declarations
declarations
-config=MET.B.VOCF_FUNC,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.CALLING

Summary

Report metric HIS.CALLING (number of calling functions).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.CALLING,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.CALLS

Summary

Report metric HIS.CALLS (number of called functions).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.CALLS,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.COMF

Summary

Report metric HIS.COMF (comment density).

Configuration

See generic service options.

Option metric_decimal_digits
metric_decimal_digits
-config=MET.HIS.COMF,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.

Default:

-config=MET.HIS.COMF,metric_decimal_digits={HIS.COMF, 1}

Option declarations
declarations
-config=MET.HIS.COMF,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.GOTO

Summary

Report metric HIS.GOTO (number of goto statements).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.GOTO,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.LEVEL

Summary

Report metric HIS.LEVEL (depth of nesting of a function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.LEVEL,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.PARAM

Summary

Report metric HIS.PARAM (number of function parameters).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.PARAM,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.PATH

Summary

Report metric HIS.PATH (number of paths).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.PATH,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.RETURN

Summary

Report metric HIS.RETURN (number of return points).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.RETURN,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.STMT

Summary

Report metric HIS.STMT (number of instructions per function).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.STMT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.VOCF

Summary

Report metric HIS.VOCF (language scope).

Configuration

See generic service options.

Option metric_decimal_digits
metric_decimal_digits
-config=MET.HIS.VOCF,metric_decimal_digits={METRIC, DEC},...

Specify the number of decimal digits shown.

The configuration’s content is list of metrics with the number of decimal digits to be shown.

METRIC:

name of a supported metric.

DEC:

the number of decimal digits. It must be an integer greater than or equal to 0.

Default:

-config=MET.HIS.VOCF,metric_decimal_digits={HIS.VOCF, 1}

Option declarations
declarations
-config=MET.HIS.VOCF,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.ap_cg_cycle

Summary

Report metric HIS.ap_cg_cycle (number of recursions).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.ap_cg_cycle,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Meter MET.HIS.v_G

Summary

Report metric HIS.v_G (cyclomatic complexity).

Configuration

See generic service options.

Option declarations
declarations
-config=MET.HIS.v_G,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


The MISRA C++:2008 Coding Rules

For the MISRA C++:2008 [64] coding rules, the exact definition takes into account all clarifications published the MISRA information and discussion forum. Note that for each of the supported MISRA C++:2008 rules, the identifier for the corresponding ECLAIR service is obtained by adding the prefix MP1., thereby obtaining, for example: MP1.0-1-1, MP1.4-10-2, MP1.8-5-2, …

Note that the page numbers included in the references to [64] in the ECLAIR service summaries are for the PDF version of [64] .

Rule MP1.0-1-1

Summary

A project shall not contain unreachable code. (See page 27 of MISRA-CPP-2008 [64] .)

Description

The rule reports:

  • unreachable code;

  • constant unfeasible code;

  • any unit compiled but not linked.

Notes:

  • A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

  • Reports for deliberately unreachable statements and expressions can be tagged using the statements service configuration.

  • Unused declarations can be tagged using the declarations service configuration; in particular, to hide declarations in public API files by:

    • using the tag hide;

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library entry points not necessarily have to be referenced."
-config=MP1.0-1-1,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Imprecision

False negatives are present because unreachable code is undecidable.

Configuration

See generic service options.

Option ignored_stmts
ignored_stmts
-config=MP1.0-1-1,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option statements
statements
-config=MP1.0-1-1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option declarations
declarations
-config=MP1.0-1-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option diagnostics
diagnostics
-config=MP1.0-1-1,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MP1.0-1-2

Summary

A project shall not contain infeasible paths. (See page 28 of MISRA-CPP-2008 [64] .)

Description

An expression is taken to be controlling if it is:

  • the left hand operand of the logical AND (&&) and logical OR (||) operators;

  • the condition part of the :? operator;

  • the condition part of an if, do, for, while or switch statement.

Notes:

  • expressions in a compile-time constant context are not reported;

  • if the condition for a while statement is the Boolean constant for true, then it is ignored;

  • if the condition for a do statement is the Boolean constant for false then it is also ignored;

  • observe that in the above allowed loop idioms, we have deliberately chosen to limit the controlling expressions of while-true and do-while-false loop idioms to Boolean constants. This is because the Exceptions on the MISRA C document allow any dowhile (evaluating either to a true value for Exception 1 and a false value for Exception 2);

  • other loop idioms can be added using the -loop_idioms global configuration;

  • in addition, reports for any statements with controlling expressions that have fixed values can be tagged using the statements service configuration.

Implementation

The rule only reports an expression if it can be detected that the expression will always have the same value.

Imprecision

False negatives are present because, in general, the fixed values of constant expressions may not be statically known.

Configuration

See generic service options.

Option statements
statements
-config=MP1.0-1-2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MP1.0-1-3

Summary

A project shall not contain unused variables. (See page 29 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.0-1-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.0-1-3,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.0-1-5

Summary

A project shall not contain unused type declarations. (See page 30 of MISRA-CPP-2008 [64] .)

Description

Note that reports about unused type declarations can be hidden using the declarations service configuration; for instance, any unused declarations in public API files can be assigned a report tag such as hide by:

  • exploiting the globally defined decl_selector __public_api_decls;

  • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Declarations in public files define a public API and do not necessarily have to be referenced."
-config=MP1.0-1-5,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.0-1-5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.0-1-5,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.0-1-6

Summary

A project shall not contain instances of non-volatile variables being given values that are never subsequently used. (See page 30 of MISRA-CPP-2008 [64] .)

Description

Due to the formulation of this rule it is only possible to identify the definitely dead code while it is not possible to distinguish possibly dead code from any other code. For this reason we suggest deviating the possible false negatives for this rule (after a check for unreported provably dead code) clarifying the insurmountable technical reason for this decision.

Imprecision

false negatives are present when the checker is unable to detect that code cannot be reached or if a variable’s value is not used after being set

Configuration

See generic service options.

Rule MP1.0-1-7

Summary

The value returned by a function having a non-void return type that is not an overloaded operator shall always be used. (See page 31 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • calls to a non-void function whose return value is ignored are reported;

  • calls where the return value is cast to void are not individually reported as the explicit cast to void is taken to be a deviation request by the user.

  • all calls are included in a statistical summary for the program and the called function;

  • the summary provides:

    • the number of calls to the function,

    • the number of times the return value is ignored but this was expected,

    • the number of times the return value is cast to void and

    • the number of times it is ignored unexpectedly;

  • the number of samples shown can be changed using the use_samples service configuration.

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=MP1.0-1-7,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option use_samples
use_samples
-config=MP1.0-1-7,use_samples={TAG, MAX},...

Specify the maximum number of samples to be output.

The configuration’s content is a list of return use tags (ignored, to_void, used) with the maximum number of samples to be output; if a use tag is not specified, then all calls matching the tag will be shown as violations.

TAG:

tag indicating the return use. Accepted values are:

  • used: return value is used;

  • ignored: return value is ignored;

  • to_void: return value is cast to void;

MAX:

maximum number of samples to be shown. It must be an integer greater than or equal to -1.

Default:

-config=MP1.0-1-7,use_samples={ignored, -1}, {to_void, 1}, {used, 1}

Option calls
calls
-config=MP1.0-1-7,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=MP1.0-1-7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.0-1-8

Summary

All functions with void return type shall have external side effect(s). (See page 32 of MISRA-CPP-2008 [64] .)

Description

A function with void return type is reported if its definition does not include one of the following:

  • a call that does not have the property noeffect;

  • a (possibly implicit) throw that is not caught within the function;

  • a call to new, delete, a non-trivial constructor or a destructor;

  • a write to a non-local or volatile variable;

  • a read from a volatile variable.

Notes:

  • A call has the property noeffect if it is declared to have the attribute const or pure or it is specified as const, pure or noeffect using -call_properties global configuration;

  • destructors are not reported because the absence of side effects is deliberate;

  • functions with the fixed_signature property (see the -call_properties global configuration) are not reported so to allow no-effects callbacks;

  • virtual methods are not reported for the same reason.

Imprecision

A call to a function that does not have the noeffect property is considered a side effect even if, with the given arguments, it cannot cause observable side effects.

This service depends upon the configuration of the following ancillary services: B.CALL.noeffect

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.0-1-8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.0-1-9

Summary

There shall be no dead code. (See page 32 of MISRA-CPP-2008 [64] .)

Description

Any expression whose value is ignored and has no side effects is reported.

Notes:

  • an action is considered to be a side effect only when it is caused by the external operator/functor of the expression (and is not just an effect of its sub-expressions);

  • an explicit cast to void is not reported.

  • initialization is not reported.

Imprecision

Cautions are reported when the checker is uncertain if the code is dead code.

It is not always possible to distinguish possibly dead code from any other code.

False negatives are present when there is a call to a void function that has no effect (external or any changes to the function’s arguments).

Configuration

See generic service options.

Rule MP1.0-1-10

Summary

Every defined function shall be called at least once. (See page 33 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • Declarations can be hidden using the declarations service configuration; in particular, to hide declarations in public API files by:

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library functions not necessarily have to be referenced."
-config=MP1.0-1-10,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.0-1-10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.0-1-10,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.0-1-11

Summary

There shall be no unused parameters (named or unnamed) in non-virtual functions. (See page 33 of MISRA-CPP-2008 [64] .)

Description

Note that the exception for unused parameters in a function that is used as a callback is not implemented.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.0-1-11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.0-1-12

Summary

There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it. (See page 34 of MISRA-CPP-2008 [64] .)

Description

Any parameter in a virtual function that is not referenced by the function definition or any function that overrides it anywhere in the project is shown.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.0-1-12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.0-1-12,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.0-2-1

Summary

An object shall not be assigned to an overlapping object. (See page 35 of MISRA-CPP-2008 [64] .)

Description

It is reported if:

  • a library function other than memmove for copying objects is used to copy (possibly) overlapping objects;

  • a member of a union is copied to another member (or subexpression of another member) of the same union that points to the same allocation area and has incompatible type; or

  • a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union.

An exception to the last item is when a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union, both members are arrays and the sub-expressions are array elements with the same type and they are at the same constant offset.

Imprecision

Cautions are reported when the analyzer is uncertain whether the objects overlap.

False positives are reported because the rule needs a deeper (much more expensive) semantic analysis.

False negatives are present because the rule needs a deeper (much more expensive) semantic analysis.

Configuration

See generic service options.

Rule MP1.0-3-1

Summary

Minimization of run-time failures shall be ensured by the use of at least one of:

  1. static analysis tools/techniques;

  2. dynamic analysis tools/techniques;

  3. explicit coding of checks to handle run-time faults.

(See page 36 of MISRA-CPP-2008 [64] .)

Description

The document service configuration should be used to specify, for each unexpected behavior kind, where the documenting comment will be found and the expected format.

The behavior kinds that are checked for documentation are:

  • overflow,

  • unexpected wrapping,

  • invalid shift,

  • division/remainder by zero,

  • unsequenced side effects,

  • read from uninitialized automatic object,

  • read from uninitialized allocated object,

  • write to string literal or const object,

  • non-volatile access to volatile object,

  • access to dead allocated object,

  • access to dead automatic object,

  • access to dead thread object,

  • access using null pointer,

  • access using invalid pointer,

  • access using out-of-bounds pointer,

  • access using unaligned pointer,

  • mistyped access to object,

  • mistyped access to function,

  • invalid pointer arithmetic,

  • invalid pointer comparison,

  • overlapping copy,

  • invalid arguments to function,

  • returned function error,

  • tainted input,

  • data race,

  • invariant violation,

  • communication error.

Using the default value for document valid documentation comments look like:

/* Documentation for MISRA C++:2008 Rule 0-3-1: overflow ... To Be Written ... */
/* Documentation for MISRA C++:2008 Rule 0-3-1: unexpected wrapping ... To Be Written ... */
/* Documentation for MISRA C++:2008 Rule 0-3-1: invalid shift ... To Be Written ... */
/* ... */
/* Documentation for MISRA C++:2008 Rule 0-3-1: communication error ... To Be Written ... */

These special comments should be placed in a compiled file, otherwise, ECLAIR will not be able to detect them. For each of them the ... To Be Written ... should be replaced with the description of what is done to minimize the risk or why the situation cannot happen or is not relevant for the project.

Configuration

See generic service options.

Option document
document
-config=MP1.0-3-1,document={ID_FMT, SUB, FILE_MATCHER, WHAT, DOC_FMT, REP_FMT},...

Specify how to extrapolate the required documentation from comments in the specified compiled source files.

The configuration’s content is a list of tuples that provide (in order) a unique identifier for the document, context and file matcher indicating where to search for the document, what to check for (e.g., missing documentation), a format for matcher to check the documentation content and a format for the reports.

ID_FMT:

format (see the -fmt global configuration content, template userdocs__id_default_fmt) for short but unique name to identify the document with field:

service

service name.

SUB:

tag indicating subject. Accepted values are:

  • unit: check all files for each translation unit;

  • file: check each file;

  • program: check all the program files;

  • project: check all the project files;

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

WHAT:

tag indicating what to report. Accepted values are:

  • duplicates: report if more than one matching document is found;

  • missing: report if no documentation is found;

  • missing_if_noted: report if no documentation is found and uses are noted;

  • all: report any duplicated or missing documentation;

  • none: do not report missing or duplicated documentation;

DOC_FMT:

format (see the -fmt global configuration content, template userdocs__document_default_fmt) specifying regular expression to match the document content with fields:

document_id

a document identifier;

file

canonical pathname;

rule

rule description;

service

service name.

REP_FMT:

format (see the -fmt global configuration content, template userdocs__default_fmt) for message to be included in the report with fields:

document_id

a document identifier;

file

canonical pathname;

error

message indicating the error kind which can be missing_file, missing_docs or duplicate_docs;

target

unit, program or project description;

service

service name.

Default:

-config=MP1.0-3-1,document={"%{__overflow_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__wrapping_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__shift_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__division_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__side_effects_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__uninit_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__write_to_const_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__non_volatile_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_alloc_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_auto_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__dead_thread_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__null_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_access_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__bounds_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__unaligned_ptr_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_object_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__mistyped_function_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_arith_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_ptr_compare_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__overlap_copy_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invalid_fun_args_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__return_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__tainted_input_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__data_race_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__invariant_viol_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"},
  {"%{__comms_error_fmt()}", project, "any()", all,
    "%{__document_rule_fmt()}", "%{__report_fmt()}"}

Option ignored_comments
ignored_comments
-config=MP1.0-3-1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.0-3-2

Summary

If a function generates error information, then that error information shall be tested. (See page 38 of MISRA-CPP-2008 [64] .)

Description

Calls to standard library functions whose return values contain error information are always checked.

To specify functions not in the standard library that return error information use the -call_properties global configuration with property error.

An error-returning function call is compliant if any of the following hold.

  • The returned value is tested directly and the result of the test is used.

  • The returned value is returned directly to the calling function which must have a similar error value expectation (that is, with the same error configuration).

  • The returned value is stored in a variable and that variable is tested in a statement that immediately follows the call in one of the following ways:

    • the test is in the condition part of an if statement;

    • the variable is in the condition expression of a switch statement, and the case and default labels select the specified error values;

    • it is a return statement that returns the result of the test.

Note that to specify the handling of a function’s error values use the handling service configuration.

For example, the configuration line:

-doc="The return value of functions matching __return_cast_minusone_errors must be assigned to a variable whose name starts with time_, then verified and returned."
-config=MP1.0-3-2,handling+={"any()", __return_cast_minusone_errors,
if, {{return_cast_minusone_tag, "return(ref(^(time_).*$))", ""}}}

specifies that for any called function with an error property that matches the selector __return_minusone_errors, (this is a builtin selector for the -function_error global configuration, that requires the error value, returned by the called function, to be -1), then:

  • the return value must be assigned to a variable that matches ^(time_).*$,

  • the variable must be tested in the condition part of an if statement and

  • returned by the calling function.

If the handling for the function error is not specified, then there is no check on any action taken when an error value is returned.

Configuration

See generic service options.

Option calls
calls
-config=MP1.0-3-2,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option handling
handling
-config=MP1.0-3-2,handling={DECL_MATCHER, ID, SLCT, {{TAG, ACTION, FMT},...}},...

Specify the error handling.

The configuration’s content is an ordered list of a declaration matcher for the calling function, an error identifier and associated data about where the error is placed, where it should be tested and what actions should be taken.

Note that the first matching clause for the calling function and error identifier will be selected and the error value is checked using the associated data

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

ID:

an identifier declared in the -function_error global configuration.

SLCT:

specifies if handling is in a switch or if statement. Accepted values are:

  • any: any selection;

  • if: if statement;

  • switch: switch statement;

TAG:

a value tag declared in the -function_error global configuration.

ACTION:

action to be taken at end of related error branch. Accepted forms are:

  • any: the action is not checked

  • return_any(): the action is to return

  • return(RETURN_VAL): the action is to return RETURN_VAL

  • return_minus(RETURN_VAL): the action is to return the negated RETURN_VAL

  • return_call(CALL_MATCHER,RETURN_VAL): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression) where the RETURN_VAL is an argument to the call; the called function must have a noreturn attribute (see the -decl_properties global configuration)

  • goto(REGEX): the action is a goto statement with label matching REGEX

  • throw(TYPE_MATCHER): the action is a throw statement with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • call(CALL_MATCHER): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression)

  • switch(FUNCTION_ERROR): the action is a switch statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

  • if(FUNCTION_ERROR): the action is an if statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

REGEX

accepted forms are:

RETURN_VAL

accepted forms are:

  • return_value(): the returned value

  • INTEGER: the value

  • STMT_MATCHER: a sub-expression of an expression matching STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template callpost__default_fmt) to specify the message describing ACTION.

Default:

-config=MP1.0-3-2,handling={}

Rule MP1.0-4-1

Summary

Use of scaled-integer or fixed-point arithmetic shall be documented. (See page 39 of MISRA-CPP-2008 [64] .)

Description

The default requirement is that the documentation is included in a comment (containing the string scaled-integer or fixed-point arithmetic) in one of the project’s source file.

This requirement can be modified using the document service configuration.

Configuration

See generic service options.

Option document
document
-config=MP1.0-4-1,document={ID_FMT, SUB, FILE_MATCHER, WHAT, DOC_FMT, REP_FMT},...

Specify how to extrapolate the required documentation from comments in the specified compiled source files.

The configuration’s content is a list of tuples that provide (in order) a unique identifier for the document, context and file matcher indicating where to search for the document, what to check for (e.g., missing documentation), a format for matcher to check the documentation content and a format for the reports.

ID_FMT:

format (see the -fmt global configuration content, template userdocs__id_default_fmt) for short but unique name to identify the document with field:

service

service name.

SUB:

tag indicating subject. Accepted values are:

  • unit: check all files for each translation unit;

  • file: check each file;

  • program: check all the program files;

  • project: check all the project files;

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

WHAT:

tag indicating what to report. Accepted values are:

  • duplicates: report if more than one matching document is found;

  • missing: report if no documentation is found;

  • missing_if_noted: report if no documentation is found and uses are noted;

  • all: report any duplicated or missing documentation;

  • none: do not report missing or duplicated documentation;

DOC_FMT:

format (see the -fmt global configuration content, template userdocs__document_default_fmt) specifying regular expression to match the document content with fields:

document_id

a document identifier;

file

canonical pathname;

rule

rule description;

service

service name.

REP_FMT:

format (see the -fmt global configuration content, template userdocs__default_fmt) for message to be included in the report with fields:

document_id

a document identifier;

file

canonical pathname;

error

message indicating the error kind which can be missing_file, missing_docs or duplicate_docs;

target

unit, program or project description;

service

service name.

Default:

-config=MP1.0-4-1,document={"%{__fixpt_integer_fmt()}", project, "any()", all, "%{__document_fixpt_integer_fmt()}", "%{__report_fixpt_integer_fmt()}"}

Option ignored_comments
ignored_comments
-config=MP1.0-4-1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.0-4-2

Summary

Use of floating-point arithmetic shall be documented. (See page 39 of MISRA-CPP-2008 [64] .)This service depends upon the configuration of the following ancillary services: STD.floatstd

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.0-4-2,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MP1.0-4-2,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MP1.0-4-2,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MP1.0-4-3

Summary

Floating-point implementations shall comply with a defined floating-point standard. (See page 39 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • the STD.floatstd behavior service configuration can be used to specify the documentation;

  • the report will show a sample use of floating point type with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.floatstd

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.0-4-3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MP1.0-4-3,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MP1.0-4-3,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MP1.1-0-1

Summary

All code shall conform to ISO/IEC 14882:2003 “The C++ Standard Incorporating Technical Corrigendum 1”. (See page 40 of MISRA-CPP-2008 [64] .)This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptmarg STD.enumlist STD.extident STD.flexaray STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.1-0-1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=MP1.1-0-1,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=MP1.1-0-1,standards=c++03

Rule MP1.1-0-2

Summary

Multiple compilers shall only be used if they have a common, defined interface. (See page 40 of MISRA-CPP-2008 [64] .)

Description

Compilers can be white-listed using the compilers service configuration.

For example, with the configuration lines:

-tool_tag={any_g,"language(c)&&tool(^gcc[^/]*$) || language(c++)&&tool(^g\\+\\+[^/]*$)"}
-config=MP1.1-0-2,compilers=any_g

all gcc and g++ compilers are taken to be compatible.

Implementation

Reports if more than one compiler that is not white-listed is used to compile and link the program.

Configuration

See generic service options.

Option compilers
compilers
-config=MP1.1-0-2,compilers=TOOL_MATCHER,...

Specify the tool tags; compilers are taken to be compatible if and only if they have the same tag.

The configuration’s content is a list of tags matching compatible compilers.

TOOL_MATCHER:

a -tool_tag identifier or a matcher expression whose matching compilers are all considered as compatible.


Rule MP1.1-0-3

Summary

The implementation of integer division in the chosen compiler shall be determined and documented. (See page 41 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • the STD.divrmsgn behavior service configuration can be used to specify the expected direction of rounding when dividing two signed integers;

  • the report will show a sample use of integer division with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.divrmsgn

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.1-0-3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MP1.1-0-3,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MP1.1-0-3,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MP1.2-2-1

Summary

The character set and the corresponding encoding shall be documented. (See page 41 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • any character sets for coding and execution may be used, provided they are documented;

  • the STD.charsmap behavior, the STD.charsmem behavior and the STD.charsval behavior service configurations can be used to specify and document the supported character sets;

  • for each non-standard or unspecified character used, the report will show samples with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.charsmap STD.charsmem STD.charsval

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.2-2-1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MP1.2-2-1,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MP1.2-2-1,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MP1.2-3-1

Summary

Trigraphs shall not be used. (See page 41 of MISRA-CPP-2008 [64] .)

Description

Note that trigraphs are sequences denoted by ??=, ??(, ??<, ??/, ??), ??>, ??', ??|, and ??-.

Configuration

See generic service options.

Rule MP1.2-5-1

Summary

Digraphs should not be used. (See page 42 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.2-7-1

Summary

The character sequence /* shall not be used within a C-style comment. (See page 42 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option comments
comments
-config=MP1.2-7-1,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=MP1.2-7-1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.2-7-2

Summary

Sections of code shall not be “commented out” using C-style comments. (See page 43 of MISRA-CPP-2008 [64] .)

Description

To detect code, it is checked if a statistical measure (based on the length, number of keywords and operators in the comment) is exceeded.

This can have both false positives and negatives due to the lack of precision in the measures used to detect code.

Note that, by default, doxygen comments are ignored; this can be changed using the comments service configuration.

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

There exists no way to distinguish code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

/* This is a comment */

Configuration

See generic service options.

Option comments
comments
-config=MP1.2-7-2,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=MP1.2-7-2,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=MP1.2-7-2,code_lines=0

Option ignored_comments
ignored_comments
-config=MP1.2-7-2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MP1.2-7-2,ignored_comments=__doxygen_comments

Rule MP1.2-7-3

Summary

Sections of code should not be “commented out” using C++ comments. (See page 43 of MISRA-CPP-2008 [64] .)

Description

To detect code, it is checked if a statistical measure (based on the length, number of keywords and operators in the comment) is exceeded.

This can have both false positives and negatives due to the lack of precision in the measures used to detect code.

Note that, by default, doxygen comments are ignored; this can be changed using the comments service configuration.

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

There exists no way to distinguish code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

// This is a comment

Configuration

See generic service options.

Option comments
comments
-config=MP1.2-7-3,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=MP1.2-7-3,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=MP1.2-7-3,code_lines=0

Option ignored_comments
ignored_comments
-config=MP1.2-7-3,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MP1.2-7-3,ignored_comments=__doxygen_comments

Rule MP1.2-10-1

Summary

Different identifiers shall be typographically unambiguous. (See page 44 of MISRA-CPP-2008 [64] .)

Description

Identifiers are typographically ambiguous if, after any one of the following two sequences of character replacements (done in the specified order) they result in identical strings:

  1. replacement of 0 by O;

  2. replacement of 1 by I;

  3. replacement of l by I;

  4. replacement of 5 by S;

  5. replacement of 2 by Z;

  6. replacement of h by n;

  7. replacement of 8 by B;

  8. replacement of m by rn;

or

  1. removal of any underscore character;

  2. replacement of lowercase letters by uppercase.

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MP1.2-10-1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MP1.2-10-1,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.2-10-2

Summary

Identifiers declared in an inner scope shall not hide an identifier declared in an outer scope. (See page 45 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option similar_map
similar_map
-config=MP1.2-10-2,similar_map={MATCH_ID, MAPPING},...

Specify mappings of identifiers to their canonical form.

The configuration’s content is a list of identifier mappings.

MATCH_ID:

the identifier for the selected entities.

MAPPING:

. Accepted forms are:

  • std(REGEX): matches a service

  • min(NUMBER,CASE): the identifier prefix of length NUMBER, (after convertion to upper-case, if CASE is case_insensitive), is the canonical form

  • REPLACER[||REPLACER]*): a list of alternative REPLACERs (see the -replacer global configuration) defining the replacements that map the identifier to its canonical forms

CASE

accepted forms are:

  • case_sensitive: the identifier is case-sensitive

  • case_insensitive: the identifier is case-insensitive and the canonical form has all letters converted to upper-case

Default:

-config=MP1.2-10-2,similar_map={introduces_id_entity, $0}

Option ignored_decls
ignored_decls
-config=MP1.2-10-2,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MP1.2-10-2,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.2-10-3

Summary

A typedef name (including qualification, if any) shall be a unique identifier. (See page 45 of MISRA-CPP-2008 [64] .)

Description

There are two exceptions:

  • both entities are typedefs with the same declaration in a header file that is included in multiple source files;

  • the other entity is a struct, union or enum tag associated with the same typedef.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MP1.2-10-3,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MP1.2-10-3,reuse_by_location=address

Rule MP1.2-10-4

Summary

A class, union or enum name (including qualification, if any) shall be a unique identifier. (See page 46 of MISRA-CPP-2008 [64] .)

Description

There are two exceptions:

  • both entities are tag names with the same declaration in a header file that is included in multiple source files;

  • the other entity is a typedef tag associated with the same struct, union or enum.

Configuration

See generic service options.

Option reuse_by_location
reuse_by_location
-config=MP1.2-10-4,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MP1.2-10-4,reuse_by_location=address

Rule MP1.2-10-5

Summary

The identifier name of a non-member object or function with static storage duration should not be reused. (See page 46 of MISRA-CPP-2008 [64] .)

Exceptions

  • an object or function with internal linkage may be defined in more than one translation unit provided all such definitions are made in the same header file that is included in each unit;

  • visible function identifiers that form an overload set shall be considered as the same entity.

Configuration

See generic service options.

Option summarize_max
summarize_max
-config=MP1.2-10-5,summarize_max=MAX

Specify the maximum number of clashes to be shown.

MAX:

if Max = -1 or the number of clashes for an identifier is less than or equal to Max, then all the clashes are shown. Otherwise only Max clashes are shown and a program summary will show the total number of clashes for that identifier. It must be an integer greater than or equal to -1.

Default:

-config=MP1.2-10-5,summarize_max=0

Option reuse_by_location
reuse_by_location
-config=MP1.2-10-5,reuse_by_location=REUSE

Specify identifier reuse at same location.

REUSE:

identifier reuse at same location. Accepted values are:

  • entity: all entities with the same name will be reported;

  • address: all entities with the same name will be reported only if they do not all share the same declaration location;

Default:

-config=MP1.2-10-5,reuse_by_location=address

Rule MP1.2-10-6

Summary

If an identifier refers to a type, it shall not also refer to an object or a function in the same scope. (See page 47 of MISRA-CPP-2008 [64] .)

Description

See also MISRA forum thread “Rule 2-10-6”

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=MP1.2-10-6,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MP1.2-10-6,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.2-13-1

Summary

Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used. (See page 47 of MISRA-CPP-2008 [64] .)

Description

The list of compliant escape sequences is also given on page 47 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Rule MP1.2-13-2

Summary

Octal constants (other than zero) and octal escape sequences (other than “\0”) shall not be used. (See page 48 of MISRA-CPP-2008 [64] .)

Exceptions

The integer constant 0 and the octal escape sequence \0 are allowed.

Configuration

See generic service options.

Option literals
literals
-config=MP1.2-13-2,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP1.2-13-3

Summary

A U suffix shall be applied to all octal or hexadecimal integer literals of unsigned type. (See page 48 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • the context in which the constant is used is not relevant (see the MISRA forum thread “Assigning literal 0 to an unsigned variable”);

  • the compliant use of suffix u is for conformance with the corresponding Rule 7.2 on page 68 of MISRA C:2012 [45] ;

  • the inferred type for the integer constants is based on the table on page 56 of the C99 standard [37].

Configuration

See generic service options.

Option literals
literals
-config=MP1.2-13-3,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP1.2-13-4

Summary

Literal suffixes shall be upper case. (See page 49 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option literals
literals
-config=MP1.2-13-4,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP1.2-13-5

Summary

Narrow and wide string literals shall not be concatenated. (See page 49 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.3-1-1

Summary

It shall be possible to include any header file in multiple translation units without violating the One Definition Rule. (See page 50 of MISRA-CPP-2008 [64] .)

Description

Note that a header file is any file that is included via the #include directive, regardless of name or suffix (see Section 6.3, page 50 MISRA C++:2008 [64] ).

Exceptions

Inline functions and definitions in the context of a template declaration (class or function) are not reported.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-1-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-1-2

Summary

Functions shall not be declared at block scope. (See page 50 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-1-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-1-3

Summary

When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization. (See page 51 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-1-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-2-1

Summary

All declarations of an object or function shall have compatible types. (See page 52 of MISRA-CPP-2008 [64] .)

Description

More specifically:

  • if a variable is declared more than once, the types must be compatible;

  • if a function has more than one prototype declaration or definition, the corresponding parameter types or return types must be compatible.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-2-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-2-3

Summary

A type, object or function that is used in multiple translation units shall be declared in one and only one file. (See page 53 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-2-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-2-4

Summary

An identifier with external linkage shall have exactly one definition. (See page 53 of MISRA-CPP-2008 [64] .)

Description

See [basic.def.odr] in C++ standard 2003 [38]

It is reported if any variable, function, or template thereof with external linkage has:

  • no definition; or

  • multiple non-inline definitions in different translation units; or

  • multiple inline definitions in different translation units that are not the same; or

  • different initializer values.

Note that by inline, we include here all the entities specified in paragraph 6 of [basic.def.odr] in C++ standard 2017 [42].

Imprecision

when the analyzer is unsure is a function template definition is an overload, the definition is reported as a caution.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-2-4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-3-1

Summary

Objects or functions with external linkage shall be declared in a header file. (See page 54 of MISRA-CPP-2008 [64] .)

Description

More specifically:

  • any variable or function with external linkage and not declared in an anonymous namespace must be declared in a header file;

  • any variable or function that is not declared in a header file or in an anonymous namespace must have internal linkage.

Hence a variable or function is reported if:

  • it has external linkage; and

  • the declaration or definition is not in a public API file.

  • if it is referenced, then all references to it are in the same function.

A file can be declared part of a public API by:

  • exploiting the globally defined decl_selector __public_api_decls;

  • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

functions and variables declared in files whose names match the regular expression ^my_public_header.h$ will not be reported.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-3-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-3-2

Summary

If a function has internal linkage then all re-declarations shall include the static storage class specifier. (See page 55 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-3-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-4-1

Summary

An identifier declared to be an object or type shall be defined in a block that minimizes its visibility. (See page 55 of MISRA-CPP-2008 [64] .)

Description

In particular, the rule reports any variable for which one of the following holds:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • its declaration can be moved to the initialization of a for statement;

  • it is not a constant or volatile (see “Rule 3-4-1 and defining constants in one place”).

Note that if the variable has a non-constant initialization, the report will be a caution.

Imprecision

Cautions are reported when the variable has a non-constant initialization.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-4-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.3-4-1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.3-9-1

Summary

The types used for an object, a function return type, or a function parameter shall be token-for-token identical in all declarations and re-declarations. (See page 56 of MISRA-CPP-2008 [64] .)

Description

Note that this rule does not distinguish between the ordering of specifiers and qualifiers or whether the specifiers are implicit or explicitly written (for instance, ‘int’, ‘signed’, ‘signed int’ and ‘int signed’ are interpreted by this rule as identical types).

Configuration

See generic service options.

Option const_pass_by_value
const_pass_by_value
-config=MP1.3-9-1,const_pass_by_value=BOOL

Specify if constant pass-by-value should be checked.

BOOL

Accepted values are:

  • false: constant pass-by-value is not checked;

  • true: constant pass-by-value is checked;

Default:

-config=MP1.3-9-1,const_pass_by_value=false

Option declarations
declarations
-config=MP1.3-9-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.3-9-2

Summary

typedefs that indicate size and signedness should be used in place of the basic numerical types. (See page 56 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • The ISO (POSIX) typedefs are taken as the default schema.

  • The naming service configuration can be used to change the schema.

Configuration

See generic service options.

Option naming
naming
-config=MP1.3-9-2,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MP1.3-9-2,naming=mp1

Option declarations
declarations
-config=MP1.3-9-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP1.3-9-2,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP1.3-9-3

Summary

The underlying bit representations of floating-point values shall not be used. (See page 57 of MISRA-CPP-2008 [64] .)

Description

To be more specific, the rule will report:

  1. any type conversion between a pointer to a floating-point type and a pointer to any other type, unless the conversion maps a pointer to (array of) floating-point type to a pointer to (array of) the same floating-point type, where the number and size of array constructions may differ;

  2. any object declaration with union type that has a member with floating-point type;

  3. any object declaration with a (possibly recursive) struct type that has a single member with union type and this has a member of floating-point type;

  4. if a union type with a member of floating-point type is referred to by a compound literal expression.

Note that the service has false positives with respect to the original (undecidable) MISRA rule.

For example, any cast of a pointer to a floating-point type to a pointer to int is reported although, in general, this will not lead to accessing the underlying floating-point representation.

Imprecision

False positives are reported because the checker may not be sure if there is access to the memory area where a floating point object is stored.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.3-9-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option casts
casts
-config=MP1.3-9-3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.4-5-1

Summary

Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator =, the logical operators &&, ||, !, the equality operators == and !=, the unary & operator, and the conditional operator. (See page 58 of MISRA-CPP-2008 [64] .)

Description

More specifically, expressions that have type bool must only be used in one of the following ways:

  • as operands of the builtin operators =, &&, ||, !, =, ==, or !=, where the type of the Boolean expression is not converted to another type.

  • as arguments to function calls where the corresponding parameter also has type bool,

  • in a return statement where the return type is bool,

  • for an object initialization where the type of the object being initialized is bool.

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.4-5-1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.4-5-2

Summary

Expressions with type enum shall not be used as operands to built-in operators other than the subscript operator [ ], the assignment operator =, the equality operators == and !=, the unary & operator, and the relational operators <, <=, >, >=. (See page 58 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.4-5-2,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.4-5-3

Summary

Expressions with type (plain) char and wchar_t shall not be used as operands to built-in operators other than the assignment operator =, the equality operators == and !=, and the unary & operator. (See page 59 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.4-5-3,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.4-10-1

Summary

NULL shall not be used as an integer value. (See page 60 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.4-10-2

Summary

Literal zero (0) shall not be used as the null-pointer-constant. (See page 60 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.5-0-1

Summary

The value of an expression shall be the same under any order of evaluation that the standard permits. (See page 71 of MISRA-CPP-2008 [64] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule MP1.5-0-2

Summary

Limited dependence should be placed on C++ operator precedence rules in expressions. (See page 73 of MISRA-CPP-2008 [64] .)

Description

Reports an expression if any of the following hold:

  • the expression has the form E0 OP E1 OPEn, the operator OP is the builtin + or * and either one of the expressions E0, …, En has a non-integral type or:

    • the promoted (integral) types of E0, …, En are I0, …, In,

    • the first type in the sequence { unsigned long long, long long, unsigned long, long, unsigned int, int {}}, that is also in I0, …, In is Ii,

    • there are at least two other types in I0, …, In that are strictly later in the sequence than Ii;

  • the expression has the form E0 OP1 E1 OP2 E2 where OP1 and OP2 are assignment operators;

  • the expression has the form E0 OP E1 OP E2 where OP is a relational, equality, logical or arithmetic operator other than +, *, &&, ||, &, |, ^;

  • the expression has the form E0 OP1 E1 OP2 E2 where OP1 is a relational, equality, logical or arithmetic operator, OP2 is any binary operator and OP1 differs from OP2;

  • the expression is conditional and has a conditional or binary sub-expression.

The trusted_pairs service configuration can be used to specify report tags for selected pairs of operators where the first matches the expression’s main operator and the second matches an operator of one of its operands. For example:

-doc="Programmers are aware of the precedence between relational and arithmetic operators, no developer confusion possible."
-config=MP1.5-0-2,trusted_pairs={safe, "relational:arithmetic"}

will deviate reports for expressions such as a > b+c and b+c < a.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MP1.5-0-2,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MP1.5-0-3

Summary

A cvalue expression shall not be implicitly converted to a different underlying type. (See page 74 of MISRA-CPP-2008 [64] .)

Description

Note that the terms underlying type and cvalue expression are defined in Section 6.5.0, page 64 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-3,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-4

Summary

An implicit integral conversion shall not change the signedness of the underlying type. (See page 74 of MISRA-CPP-2008 [64] .)

Description

Note that the term underlying type is defined in Section 6.5.0, page 64 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-4,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-5

Summary

There shall be no implicit floating-integral conversions. (See page 75 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-0-5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-0-6

Summary

An implicit integral or floating-point conversion shall not reduce the size of the underlying type. (See page 75 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-6,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-7

Summary

There shall be no explicit floating-integral conversions of a cvalue expression. (See page 76 of MISRA-CPP-2008 [64] .)

Description

Note that the term cvalue expression is defined in Section 6.5.0, page 66 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-0-7,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-0-8

Summary

An explicit integral or floating-point conversion shall not increase the size of the underlying type of a cvalue expression. (See page 77 of MISRA-CPP-2008 [64] .)

Description

Note that the term cvalue is defined in Section 6.5.0, page 66 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-8,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-9

Summary

An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expression. (See page 77 of MISRA-CPP-2008 [64] .)

Description

Note that the terms underlying type and cvalue expression are defined in Section 6.5.0, page 66 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-9,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-10

Summary

If the bitwise operators ~ and << are applied to an operand with an underlying type of unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand. (See page 77 of MISRA-CPP-2008 [64] .)

Description

More specifically, one of the following must hold:

  1. the result is immediately cast to the type of the operand;

  2. the result is immediately assigned to an object of the same underlying type as the operand;

  3. the bitwise expression is used as a function argument of the same underlying type as the operator;

  4. the bitwise expression is used as a return expression of a function whose return type is of the same underlying type as the operator.

Note that the term underlying type is defined in, Section 6.5.0, page 64 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Rule MP1.5-0-11

Summary

The plain char type shall only be used for the storage and use of character values. (See page 78 of MISRA-CPP-2008 [64] .)

Description

It follows that an object of plain char type must be one of the following:

  • an operand of the binary operators =, == or !=,

  • an operand of an explicit cast to an integral type,

  • the second or third operand of the conditional operator.

Note that explicit casts are permitted.

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-11,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-12

Summary

signed char and unsigned char type shall only be used for the storage and use of numeric values. (See page 79 of MISRA-CPP-2008 [64] .)

Description

Note that explicit casts to non-numeric values are permitted.

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-12,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-13

Summary

The condition of an if-statement and the condition of an iteration-statement shall have type bool. (See page 79 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-13,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-14

Summary

The first operand of a conditional-operator shall have type bool. (See page 80 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-14,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-0-15

Summary

Array indexing shall be the only form of pointer arithmetic. (See page 81 of MISRA-CPP-2008 [64] .)

Description

The increment and decrement operators on pointers that point to an array are allowed.

Imprecision

Cautions for array subscript expressions are reported when it cannot be determined whether the expression refers to an array.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.5-0-15,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.5-0-16

Summary

A pointer operand and any pointer resulting from pointer arithmetic using that operand shall both address elements of the same array. (See page 82 of MISRA-CPP-2008 [64] .)

Imprecision

Cautions are reported for every suspect case found.

False negatives are present when the checker precision is insufficient.

Configuration

See generic service options.

Rule MP1.5-0-17

Summary

Subtraction between pointers shall only be applied to pointers that address elements of the same array. (See page 83 of MISRA-CPP-2008 [64] .)

Description

Note that, for this rule, there is no requirement that the pointers have array types.

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported. For example, with the configuration line:

-decl_properties+={"^(data_end|data_start)$", {"alloc_id(alloc_data)"}}
extern char data_start[];
extern const char data_end[];

int main() {
char * p = data_end - data_start;
}

the subtraction data_end-data_start is not reported.

Imprecision

Cautions are reported when the checker is uncertain whether the pointer points to an array.

Configuration

See generic service options.

Rule MP1.5-0-18

Summary

>, >=, <, <= shall not be applied to objects of pointer type, except where they point to the same array. (See page 83 of MISRA-CPP-2008 [64] .)

Description

Note that, for this rule, there is no requirement that the pointers have array types.

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported.

Imprecision

Cautions are reported when the checker is uncertain whether the pointer points to an array.

Configuration

See generic service options.

Rule MP1.5-0-19

Summary

The declaration of objects shall contain no more than two levels of pointer indirection. (See page 84 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.5-0-20

Summary

Non-constant operands to a binary bitwise operator shall have the same underlying type. (See page 85 of MISRA-CPP-2008 [64] .)

Description

Note that the term underlying type is defined in Section 6.5.0, page 64 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Rule MP1.5-0-21

Summary

Bitwise operators shall only be applied to operands of unsigned underlying type. (See page 86 of MISRA-CPP-2008 [64] .)

Description

Note that the term underlying type is defined in Section 6.5.0, page 64 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-0-21,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-2-1

Summary

Each operand of a logical && or || shall be a postfix-expression. (See page 86 of MISRA-CPP-2008 [64] .)

Exceptions

Parentheses are not needed in an expression consisting of a sequence of && or a sequence of ||.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MP1.5-2-1,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MP1.5-2-2

Summary

A pointer to a virtual base class shall only be cast to a pointer to a derived class by means of dynamic_cast. (See page 87 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-2,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-3

Summary

Casts from a base class to a derived class should not be performed on polymorphic types. (See page 87 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-4

Summary

C-style casts (other than void casts) and functional notation casts (other than explicit constructor calls) shall not be used. (See page 88 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-5

Summary

A cast shall not remove any const or volatile qualification from the type of a pointer or reference. (See page 89 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-6

Summary

A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type. (See page 90 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-6,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-7

Summary

An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly. (See page 90 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-7,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-8

Summary

An object with integer type or pointer to void type shall not be converted to an object with pointer type. (See page 91 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-8,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-9

Summary

A cast should not convert a pointer type to an integral type. (See page 91 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-9,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-2-10

Summary

The increment (++) and decrement (--) operators should not be mixed with other operators in an expression. (See page 92 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option effects
effects
-config=MP1.5-2-10,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MP1.5-2-11

Summary

The comma operator, && operator and the || operator shall not be overloaded. (See page 92 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.5-2-11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.5-2-12

Summary

An identifier with array type passed as a function argument shall not decay to a pointer. (See page 93 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option casts
casts
-config=MP1.5-2-12,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP1.5-3-1

Summary

Each operand of the ! operator, the logical && or the logical || operators shall have type bool. (See page 93 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-3-1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-3-2

Summary

The unary minus operator shall not be applied to an expression whose underlying type is unsigned. (See page 94 of MISRA-CPP-2008 [64] .)

Description

Note that the term underlying type is defined in Section 6.5.0, page 64 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.5-3-2,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.5-3-3

Summary

The unary & operator shall not be overloaded. (See page 94 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.5-3-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.5-3-4

Summary

Evaluation of the operand to the sizeof operator shall not contain side effects. (See page 95 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option effects
effects
-config=MP1.5-3-4,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MP1.5-8-1

Summary

The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand. (See page 96 of MISRA-CPP-2008 [64] .)

Imprecision

Cautions are reported when values on the right-hand side of shift operators have not been determined.

Configuration

See generic service options.

Rule MP1.5-14-1

Summary

The right hand operand of a logical && or || operator shall not contain side effects. (See page 96 of MISRA-CPP-2008 [64] .)

Description

It is assumed that a call to a function has side effects unless the call is declared to have impact property const, pure or noeffect.

The -call_properties global configuration can be used to specify the call property. For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when the right operand is a call to a function not declared to be noeffect.

Configuration

See generic service options.

Option effects
effects
-config=MP1.5-14-1,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MP1.5-18-1

Summary

The comma operator shall not be used. (See page 97 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option statements
statements
-config=MP1.5-18-1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.5-18-1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP1.5-19-1

Summary

Evaluation of constant unsigned integer expressions should not lead to wrap-around. (See page 98 of MISRA-CPP-2008 [64] .)

Description

Note that this applies to preprocessor conditional expressions as well as source code expressions.

Configuration

See generic service options.

Rule MP1.6-2-1

Summary

Assignment operators shall not be used in sub-expressions. (See page 99 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option statements
statements
-config=MP1.6-2-1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.6-2-1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP1.6-2-2

Summary

Floating-point expressions shall not be directly or indirectly tested for equality or inequality. (See page 99 of MISRA-CPP-2008 [64] .)

Exceptions

Note that comparison with 0.0 can be exempted using the statements service configuration.

Implementation

Floating-point expressions are non-compliant if they are used:

  1. as operands f1 and f2 in explicit equality and inequality comparisons f1 == f2 and f1 != f2;

  2. as arguments to boolean operators &&, || or !;

  3. as the conditions for if, for, do, and while statements;

  4. in indirect tests for equality for floating point expressions (f1 op1 f2) && (f3 op2 f4), where op1 and op2 are relational operators <=, >=, < or > and either op1 is the inverse of op2, the expressions f1 and f3 are equivalent, and the expressions f2, f4 are equivalent, or op1 and op2 are the same, the expressions f1, f4 are equivalent and the expressions f2, f3 are equivalent.

Note that in item 4, for this rule, expressions e1, e2 are taken to be equivalent, if, after dropping any parentheses and unary + operators:

  • they are the same variable or literal;

  • have the same operator and have equivalent arguments;

  • have the forms f1 op f2 and f3 op f4 where op is a non-assignment binary operator, the expressions f1, f3 are equivalent and the expressions f2, f4 are equivalent or op is one of the commuting operators + or * and the expressions f1, f4 are equivalent and the expressions f2, f3 are equivalent.

Imprecision

false negatives are present because recognising indirect equality and inequality tests is undecidable

Configuration

See generic service options.

Option statements
statements
-config=MP1.6-2-2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option ignored_stmts
ignored_stmts
-config=MP1.6-2-2,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MP1.6-2-3

Summary

Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment, provided that the first character following the null statement is a white-space character. (See page 100 of MISRA-CPP-2008 [64] .)

Description

In particular, the null statement must:

  • not be preceded on the same source line by a comment;

  • not immediately followed by any character other than a white space character;

  • have any text apart from white-space characters and comments on the same source line.

Configuration

See generic service options.

Rule MP1.6-3-1

Summary

The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement. (See page 100 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.6-4-1

Summary

An if ( condition ) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement. (See page 101 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.6-4-2

Summary

All if ... else if constructs shall be terminated with an else clause. (See page 102 of MISRA-CPP-2008 [64] .)

Description

Reports any if statement if the final else if:

  • has no else clause,

  • has an else clause that is the null statement, or

  • has an else clause that is an empty compound statement and there is no comment as to why it is empty.

The default configuration does not check the content or style of the comment; however the else_empty service configuration can be used to provide a comment matcher .

Configuration

See generic service options.

Option else_empty
else_empty
-config=MP1.6-4-2,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MP1.6-4-2,else_empty={missing, "none()"}, {null, "none()"}, {empty_compound, "any()"}

Option ignored_comments
ignored_comments
-config=MP1.6-4-2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.6-4-3

Summary

A switch statement shall be a well-formed switch statement. (See page 102 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option terminals
terminals
-config=MP1.6-4-3,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MP1.6-4-3,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MP1.6-4-3,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.6-4-4

Summary

A switch-label shall only be used when the most closely-enclosing compound statement is the body of a switch statement. (See page 104 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option switch_clauses
switch_clauses
-config=MP1.6-4-4,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MP1.6-4-4,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.6-4-5

Summary

An unconditional throw or break statement shall terminate every non-empty switch-clause. (See page 104 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option terminals
terminals
-config=MP1.6-4-5,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MP1.6-4-5,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MP1.6-4-5,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.6-4-6

Summary

The final clause of a switch statement shall be the default-clause. (See page 105 of MISRA-CPP-2008 [64] .)

Description

A comment may be used in place of the default clause. To specify the allowed form of the comment use the replacement_comment service configuration.

For example, with the configuration line:

-doc="Only Fall through to next statement comments are accepted in place of the default clause."
-config=MP1.6-4-6,
  +replacement_comment={missing_terminal,
      "^.*([fF]all[- ]?[tT]hr(ough|u)|FALL[- ]?THR(OUGH|U))(s?).*$"}

the service will accept comments such as

Fall through to next statement

but not other comments such as

no default needed

as acceptible alternatives to a default clause.

Configuration

See generic service options.

Option replacement_comment
replacement_comment
-config=MP1.6-4-6,replacement_comment={WHEN, COMMENT_MATCHER},...

Specify matchers for replacement comments.

The configuration’s content is a list of pairs indicating when a comment is needed and a comment matcher.

WHEN:

when to check a comment replacement. Accepted values are:

  • empty_default: switch default clause is empty;

  • missing_terminal: case or default clause has no terminal statement;

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MP1.6-4-6,replacement_comment={empty_default,
    "any()"}

Option switch_clauses
switch_clauses
-config=MP1.6-4-6,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MP1.6-4-6,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP1.6-4-7

Summary

The condition of a switch statement shall not have bool type. (See page 106 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.6-4-7,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.6-4-8

Summary

Every switch statement shall have at least one case-clause. (See page 106 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.6-4-8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.6-5-1

Summary

A for loop shall contain a single loop-counter which shall not have floating type. (See page 107 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • a loop-control-variable is a variable occurring in the head of a for statement;

  • a loop-counter is a loop-control-variable that is an operand to a relational operator in the condition and modified in the after parts of the for statement.

Note that if the loop counter is non-compliant, then the report relating to this can be tagged using for_counter service configuration. For example:

-doc="For with multiple loop counters."
-config=MP1.6-5-1,for_counter+={multi_tag, "!single()"}}

will tag the violation report for a for statement that has more than one loop counter.

Configuration

See generic service options.

Option for_counter
for_counter
-config=MP1.6-5-1,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Rule MP1.6-5-2

Summary

If loop-counter is not modified by -- or ++, then, within condition, the loop-counter shall only be used as an operand to <=, <, > or >=. (See page 108 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • a loop-control-variable is a variable occurring in the head of a for statement;

  • a loop-counter is a loop-control-variable that is an operand to a relational operator in the condition and modified in the after parts of the for statement.

Note that if the condition part of the head or the body of a for statement is non-compliant, then the report relating to condition part or the body can be tagged using for_parts service configuration. For example:

-doc="For with the condition part that modifies a loop counter."
-config=MP1.6-5-2,for_parts+={cond_mod_tag, "cond(counter_is_modified)"}
-doc="For with the body that modifies a loop counter."
-config=MP1.6-5-2,for_parts+={body_mod_tag, "cond(counter_is_modified)"}

will tag, with cond_mod_tag, the violation report when the condition part of the head modifies a loop counter and will tag, with body_mod_tag, the violation report when the body modifies a loop counter.

Configuration

See generic service options.

Option for_parts
for_parts
-config=MP1.6-5-2,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MP1.6-5-3

Summary

The loop-counter shall not be modified within condition or statement. (See page 108 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • a loop-control-variable is a variable occurring in the head of a for statement;

  • a loop-counter is a loop-control-variable that is an operand to a relational operator in the condition and modified in the after part of the for statement.

Note that if the the head or body of a for statement is non-compliant, then the report relating to the body can be tagged using for_parts service configuration. For example:

-doc="For with the condition part that modifies a loop counter."
-config=MP1.6-5-3,for_parts+={cond_mod_tag, "cond(counter_is_modified)"}
-doc="For with the body that modifies a loop counter."
-config=MP1.6-5-3,for_parts+={body_mod_tag, "cond(counter_is_modified)"}

will tag, with cond_mod_tag, the violation report when the condition part of the head modifies a loop counter and will tag, with body_mod_tag, the violation report when the body modifies a loop counter.

Configuration

See generic service options.

Option for_parts
for_parts
-config=MP1.6-5-3,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MP1.6-5-4

Summary

The loop-counter shall be modified by one of: –, ++, -=n, or +=n; where n remains constant for the duration of the loop. (See page 108 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • a loop-control-variable is a variable occurring in the head of a for statement;

  • a loop-counter is a loop-control-variable that is an operand to a relational operator in the condition and modified in the after part of the for statement.

Note that if the the head or body of a for statement is non-compliant, then the report relating to the body can be tagged using for_parts service configuration. For example:

-doc="For with the condition part that modifies a loop counter."
-config=MP1.6-5-4,for_parts+={cond_mod_tag, "cond(counter_is_modified)"}
-doc="For with the body that modifies a loop counter."
-config=MP1.6-5-4,for_parts+={body_mod_tag, "cond(counter_is_modified)"}

will tag, with cond_mod_tag, the violation report when the condition part of the head modifies a loop counter and will tag, with body_mod_tag, the violation report when the body modifies a loop counter.

Imprecision

Cautions are reported if the checker is not sure if the increment’s expression is constant.

Configuration

See generic service options.

Option for_parts
for_parts
-config=MP1.6-5-4,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MP1.6-5-5

Summary

A loop-control-variable other than the loop-counter shall not be modified within condition or expression. (See page 109 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • while and do-while statements are not currently checked;

  • a loop-control-variable is a variable occurring in the head of a for statement;

  • a loop-counter is a loop-control-variable that is an operand to a relational operator in the condition and modified in the after part of the for statement.

Note that if the the head or body of a for statement is non-compliant, then the report relating to the body can be tagged using for_parts service configuration. For example:

-doc="For with the condition part that modifies a loop counter."
-config=MP1.6-5-5,for_parts+={cond_mod_tag, "cond(counter_is_modified)"}
-doc="For with the body that modifies a loop counter."
-config=MP1.6-5-5,for_parts+={body_mod_tag, "cond(counter_is_modified)"}

will tag, with cond_mod_tag, the violation report when the condition part of the head modifies a loop counter and will tag, with body_mod_tag, the violation report when the body modifies a loop counter.

Imprecision

Cautions are reported if the checker is not sure if the loop counter is modified.

Configuration

See generic service options.

Option for_parts
for_parts
-config=MP1.6-5-5,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MP1.6-5-6

Summary

A loop-control-variable other than the loop-counter which is modified in statement shall have type bool. (See page 110 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • while and do-while statements are not currently checked;

  • a loop-control-variable is a variable occurring in the head of a for statement;

  • a loop-counter is a loop-control-variable that is an operand to a relational operator in the condition and modified in the after part of the for statement.

Note that if the the head or body of a for statement is non-compliant, then the report relating to the body can be tagged using for_parts service configuration. For example:

-doc="For with the condition part that modifies a loop counter."
-config=MP1.6-5-6,for_parts+={cond_mod_tag, "cond(counter_is_modified)"}
-doc="For with the body that modifies a loop counter."
-config=MP1.6-5-6,for_parts+={body_mod_tag, "cond(counter_is_modified)"}

will tag, with cond_mod_tag, the violation report when the condition part of the head modifies a loop counter and will tag, with body_mod_tag, the violation report when the body modifies a loop counter.

Configuration

See generic service options.

Option for_parts
for_parts
-config=MP1.6-5-6,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MP1.6-6-1

Summary

Any label referenced by a goto statement shall be declared in the same block, or in a block enclosing the goto statement. (See page 110 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.6-6-2

Summary

The goto statement shall jump to a label declared later in the same function body. (See page 111 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.6-6-3

Summary

The continue statement shall only be used within a well-formed for loop. (See page 111 of MISRA-CPP-2008 [64] .)

Description

Note that this service does not check if the for statement is well-formed.

Configuration

See generic service options.

Option statements
statements
-config=MP1.6-6-3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.6-6-3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP1.6-6-4

Summary

For any iteration statement there shall be no more than one break or goto statement used for loop termination. (See page 112 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.6-6-5

Summary

A function shall have a single point of exit at the end of the function. (See page 113 of MISRA-CPP-2008 [64] .)

Description

More specifically:

  • a non-void function block must have an exit node at the end of the block;

  • a function try block and each of its catch handlers must have an exit node at the end of the blocks;

  • if the exit node is return statement, then it must be the only return statement in the block or handler;

  • if the exit node is a throw expression, then it may occur more than once in the block or handler;

  • the default set of exit node kinds is return statement and throw expression, this can be changed to include a noreturn function call using the exit_kind service configuration.

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=MP1.6-6-5,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=MP1.6-6-5,exit_kind={return, only_at_end_position, true},
  {throw, anywhere, true}

Rule MP1.7-1-1

Summary

A variable which is not modified shall be const qualified. (See page 114 of MISRA-CPP-2008 [64] .)

Imprecision

False negatives are present because the single unit analyzer does not check pointers with program scope.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=MP1.7-1-1,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=MP1.7-1-1,show_declarations=all

Option single_assign
single_assign
-config=MP1.7-1-1,single_assign=BOOL

Specify if an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const.

BOOL:

boolean. Accepted values are:

  • true: an uninitialized local variable declaration with a single assignment will be considered for converting the constness to const;

  • false: an uninitialized local variable declaration with a single assignment will not be considered for converting the constness to const;

Default:

-config=MP1.7-1-1,single_assign=true

Option declarations
declarations
-config=MP1.7-1-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MP1.7-1-1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.7-1-1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.7-1-2

Summary

A pointer or reference parameter in a function shall be declared as pointer to const or reference to const if the corresponding object is not modified. (See page 115 of MISRA-CPP-2008 [64] .)

Description

Note that all the parameters for the function main are ignored.

Imprecision

False negatives are present because the single unit analyzer does not check pointers with program scope.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=MP1.7-1-2,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=MP1.7-1-2,show_declarations=all

Option declarations
declarations
-config=MP1.7-1-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MP1.7-1-2,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.7-1-2,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.7-2-1

Summary

An expression with enum underlying type shall only have values corresponding to the enumerators of the enumeration. (See page 116 of MISRA-CPP-2008 [64] .)

Description

Note that the term underlying type is defined in Section 6.5.0, page 64 of MISRA C++:2008 [64] .

Configuration

See generic service options.

Option etypes
etypes
-config=MP1.7-2-1,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule MP1.7-3-1

Summary

The global namespace shall only contain main, namespace declarations and extern "C" declarations. (See page 116 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.7-3-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option naming
naming
-config=MP1.7-3-1,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MP1.7-3-1,naming=mp1

Rule MP1.7-3-2

Summary

The identifier main shall not be used for a function other than the global function main. (See page 117 of MISRA-CPP-2008 [64] .)

Description

Additional functions can be identified as entry points to the program using the -extra_references global configuration. For example, the following configuration declares that any function with unqualified name my_main may be used as an entry point:

-extra_references+={"", "name(my_main)"}

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.7-3-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.7-3-3

Summary

There shall be no unnamed namespaces in header files. (See page 117 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.7-3-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.7-3-4

Summary

using-directives shall not be used. (See page 118 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.7-3-4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.7-3-5

Summary

Multiple declarations for an identifier in the same namespace shall not straddle a using-declaration for that identifier. (See page 119 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.7-3-5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.7-3-6

Summary

using-directives and using-declarations (excluding class scope or function scope using-declarations) shall not be used in header files. (See page 120 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.7-3-6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.7-4-1

Summary

All usage of assembler shall be documented. (See page 121 of MISRA-CPP-2008 [64] .)

Description

Assembly code can be documented by:

  • including a comment before or on the same line as the asm statement;

  • including a comment immediately before a function definition that contains only asm statements (after any macro expansion);

  • including a comment immediately before a macro definition where the body contains only asm statements;

  • including a comment immediately before a loop idiom where the body of the loop contains only asm statements.

Notes:

  • The comment must match the replacer asm_comment_repl; the default value for this replacer will match any comment but this can be changed using the -replacer global configuration.

  • By default, expressions expanded from a macro-defined do-while-zero loop idiom are considered to be loop idioms. This default can be changed using the -loop_idioms global configuration.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MP1.7-4-1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_stmts
ignored_stmts
-config=MP1.7-4-1,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MP1.7-4-2

Summary

Assembler instructions shall only be introduced using the asm declaration. (See page 121 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.7-4-3

Summary

Assembly language shall be encapsulated and isolated. (See page 121 of MISRA-CPP-2008 [64] .)

Description

A function is non-compliant if it contains an unencapsulated asm statement and a non-asm statement Notes:

  • Expressions and statements specified using the configuration parameters ignored_stmts service configurations are said to be ignored.

  • A macro that contains, other than ignored code, only asm statements is considered a valid asm encapsulator.

  • A function that contains, other than ignored code, only asm statements, possibly expanded from asm encapsulator macros, or calls to asm encapsulator functions is considered a valid asm encapsulator.

  • Any asm statements that are expanded from a macro or in a macro-defined do-while-zero loop idiom are ignored.

Configuration

See generic service options.

Option ignored_stmts
ignored_stmts
-config=MP1.7-4-3,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MP1.7-5-1

Summary

A function shall not return a reference or a pointer to an automatic variable (including parameters), defined within the function. (See page 122 of MISRA-CPP-2008 [64] .)

Imprecision

Cautions are reported when the analyzer cannot determine the necessary execution order or a returned object’s subobject.

Configuration

See generic service options.

Rule MP1.7-5-2

Summary

The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist. (See page 122 of MISRA-CPP-2008 [64] .)

Imprecision

Cautions are reported when the address is possibly passed in a function call to another automatic object of larger scope or a static object.

Configuration

See generic service options.

Rule MP1.7-5-4

Summary

Functions should not call themselves, either directly or indirectly. (See page 124 of MISRA-CPP-2008 [64] .)

Description

For any function that is non-compliant, the report will show all calls in the chain that lead to it calling itself.

Imprecision

Cautions are reported when the recursion relies on indirect function calls to form the chain.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.7-5-4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=MP1.7-5-4,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule MP1.8-0-1

Summary

An init-declarator-list or a member-declarator-list shall consist of a single init-declarator or member-declarator respectively. (See page 124 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.8-3-1

Summary

Parameters in an overriding virtual function shall either use the same default arguments as the function they override, or else shall not specify any default arguments. (See page 125 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.8-4-1

Summary

Functions shall not be defined using the ellipsis notation. (See page 126 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.8-4-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.8-4-2

Summary

The identifiers used for the parameters in a re-declaration of a function shall be identical to those in the declaration. (See page 126 of MISRA-CPP-2008 [64] .)

Description

Note that it is not reported if parameters in a templatic function differ from matching positions in any instance of the function. For example, with the code:

template<typename T>
void foo (T a) {};
template void foo(int b);

there will be no violation for parameters a and b.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.8-4-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.8-4-3

Summary

All exit paths from a function with non-void return type shall have an explicit return statement with an expression. (See page 127 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option statements
statements
-config=MP1.8-4-3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.8-4-3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=MP1.8-4-3,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MP1.8-4-4

Summary

A function identifier shall either be used to call the function or it shall be preceded by &. (See page 127 of MISRA-CPP-2008 [64] .)

Description

Note that the rule uses the semantic interpretation with respect to the phrase preceded by, as described in the MISRA forum thread “Rule 16.9”.

Note also that passing the function by pointer where the formal parameter is a pointer to the very same function type, or assigning it to a reference object is not a violation. This exception is explained in the MISRA forum thread “Rule 8-4-4 (Required) function identifier with & or ()”.

Configuration

See generic service options.

Option statements
statements
-config=MP1.8-4-4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.8-4-4,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP1.8-5-1

Summary

All variables shall have a defined value before they are used. (See page 128 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • this does not necessarily require initialization at the declaration;

  • initializing any one member of a union is not considered as (proper) initialization of the other members.

To specify the read and write properties for the called functions use the -call_properties global configuration with properties pointee_read and pointee_write for the read and write properties of non-const parameters and const_pointee_read and const_pointee_write for the read and write properties of const parameters.

Implementation

Reports if an automatic variable may be used without initialization.

Imprecision

Cautions are reported when the checker cannot determine the necessary execution order or whether all the components of a data structure have been initialized.

  • Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}
  • In the presence of backward or sideways jumps, the results are unreliable.

int p(int y) {
  int x;
  int i = 0;
loop:
  if (i < y) {
    if (i > 0) {
      return x;
    }
    x = 4;
    ++i;
    goto loop;
  }
  return 0;
}

There may be false positives when there are backward goto jumps or when the goto jumps break the control structures.

Configuration

See generic service options.

Option member_areas
member_areas
-config=MP1.8-5-1,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=MP1.8-5-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MP1.8-5-1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.8-5-2

Summary

Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures. (See page 129 of MISRA-CPP-2008 [64] .)

Description

Note that the length of string literals in character array initializers is not checked.

Configuration

See generic service options.

Rule MP1.8-5-3

Summary

In an enumerator list, the = construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized. (See page 129 of MISRA-CPP-2008 [64] .)

Description

More specifically, each enumeration initializer must satisfy one of the following:

  • none of the enumeration constants are initialised;

  • only the first enumeration constant is initialised;

  • all the enumeration constants are explicitly initialised.

In addition, the expression that defines the value of an enumeration constant must be an integral constant expression that has a value representable as an int; also in the case that only the first enumeration constant is initialised, the value must be small enough so that no subsequent value in the list will exceed the int storage used by enumeration constants (See Section 7.2 of the C++03 standard [38]).

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.8-5-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.9-3-3

Summary

If a member function can be made static then it shall be made static, otherwise if it can be made const then it shall be made const. (See page 132 of MISRA-CPP-2008 [64] .)

Description

A member function can be made static or const if such change does not violate C++ standard constraints (except the possible conflict with another member function).

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=MP1.9-3-3,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=MP1.9-3-3,show_declarations=all

Option single_assign
single_assign
-config=MP1.9-3-3,single_assign=BOOL

Specify if an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const.

BOOL:

boolean. Accepted values are:

  • true: an uninitialized local variable declaration with a single assignment will be considered for converting the constness to const;

  • false: an uninitialized local variable declaration with a single assignment will not be considered for converting the constness to const;

Default:

-config=MP1.9-3-3,single_assign=false

Option declarations
declarations
-config=MP1.9-3-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MP1.9-3-3,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP1.9-3-3,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP1.9-5-1

Summary

Unions shall not be used. (See page 133 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.9-5-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP1.9-5-1,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP1.9-6-1

Summary

When the absolute positioning of bits representing a bit-field is required, then the behaviour and packing of bit-fields shall be documented. (See page 133 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • The normative text on page 133 of MISRA C:2012 [45] adds that the packing together of short-length data to economise on storage is the only acceptable use of bit-fields and recommends that structures be declared specifically to hold the sets of bit-fields, and do not include any other data within the same structure.

  • the STD.bitfldor behavior service configuration can be used to specify the documentation;

  • the report will show a sample of expressions that have class, struct or union types that contain bit-fields; the number of samples can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.bitfldor

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.9-6-1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MP1.9-6-1,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MP1.9-6-1,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MP1.9-6-2

Summary

Bit-fields shall be either bool type or an explicitly unsigned or signed integral type. (See page 134 of MISRA-CPP-2008 [64] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.9-6-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP1.9-6-2,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP1.9-6-3

Summary

Bit-fields shall not have enum type. (See page 135 of MISRA-CPP-2008 [64] .)

Description

Note that, for this service, the report category is the enum type.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.9-6-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP1.9-6-3,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP1.9-6-4

Summary

Named bit-fields with signed integer type shall have a length of more than one bit. (See page 135 of MISRA-CPP-2008 [64] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.9-6-4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP1.9-6-4,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP1.10-1-1

Summary

Classes should not be derived from virtual bases. (See page 135 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.10-1-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.10-1-2

Summary

A base class shall only be declared virtual if it is used in a diamond hierarchy. (See page 136 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.10-1-3

Summary

An accessible base class shall not be both virtual and non-virtual in the same hierarchy. (See page 136 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.10-3-1

Summary

There shall be no more than one definition of each virtual function on each path through the inheritance hierarchy. (See page 137 of MISRA-CPP-2008 [64] .)

Description

Both declarations and definitions are considered relevant. This is because, when a non-pure virtual function is declared, it is interpreted as requiring a definition (maybe later, maybe elsewhere), as its “address” will be used to fill up the virtual table for the class.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.10-3-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.10-3-2

Summary

Each overriding virtual function shall be declared with the virtual keyword. (See page 139 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.10-3-3

Summary

A virtual function shall only be overridden by a pure virtual function if it is itself declared as pure virtual. (See page 140 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.10-3-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.11-0-1

Summary

Member data in non-POD class types shall be private. (See page 141 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.11-0-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.12-1-1

Summary

An object’s dynamic type shall not be used from the body of its constructor or destructor. (See page 141 of MISRA-CPP-2008 [64] .)

Description

In a class with a virtual method or with a virtual method in a base class, the service reports every direct use of this in each of the following contexts:

  • the typeid operator;

  • a dynamic_cast;

  • a call to a virtual function of the same class.

The following are reported as cautions:

  • a call to a non-virtual non-static method of the class;

  • a call to a function if this is passed as argument;

  • a call to a static method of the class if this is passed as argument;

  • a call to any method of a different class where this is passed as argument.

Imprecision

calls to methods and functions (as specified in the description) are reported as cautions since they may be due to an undefined use of the object’s dynamic type

Configuration

See generic service options.

Rule MP1.12-1-2

Summary

All constructors of a class should explicitly call a constructor for all of its immediate base classes and all virtual base classes. (See page 142 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.12-1-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.12-1-3

Summary

All constructors that are callable with a single argument of fundamental type shall be declared explicit. (See page 143 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.12-1-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.12-8-2

Summary

The copy assignment operator shall be declared protected or private in an abstract class. (See page 145 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.12-8-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.14-5-1

Summary

A non-member generic function shall only be declared in a namespace that is not an associated namespace. (See page 146 of MISRA-CPP-2008 [64] .)

Description

An unqualified call to a function is reported if the function is a template instantiation declared in a different namespace.

Configuration

See generic service options.

Rule MP1.14-6-1

Summary

In a class template with a dependent base, any name that may be found in that dependent base shall be referred to using a qualified-id or this->. (See page 149 of MISRA-CPP-2008 [64] .)

Description

All uses of unqualified entity names that may be found in a dependent base class are shown.

Configuration

See generic service options.

Rule MP1.14-7-1

Summary

All class templates, function templates, class template member functions and class template static members shall be instantiated at least once. (See page 151 of MISRA-CPP-2008 [64] .)

Description

Note that this rule applies only to class and function templates and method and static fields of class templates that have a definition (see “Rule 14-7-1 and templates that must be specialized”).

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.14-7-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.14-8-1

Summary

Overloaded function templates shall not be explicitly specialized. (See page 153 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.15-0-2

Summary

An exception object should not have pointer type. (See page 155 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.15-0-3

Summary

Control shall not be transferred into a try or catch block using a goto or a switch statement. (See page 156 of MISRA-CPP-2008 [64] .)

Description

Using a goto or switch statement to jump into a try or catch block is a parse error and shown as non-compliant by B.PARSER

Configuration

See generic service options.

Rule MP1.15-1-2

Summary

NULL shall not be thrown explicitly. (See page 158 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.15-1-3

Summary

An empty throw (throw;) shall only be used in the compound-statement of a catch handler. (See page 159 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option statements
statements
-config=MP1.15-1-3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.15-1-3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP1.15-3-2

Summary

There should be at least one exception handler to catch all otherwise unhandled exceptions. (See page 161 of MISRA-CPP-2008 [64] .)

Description

The body of main or any other top-level function must be either:

  • a function-try-block with a catch-all handler; or

  • a compound statement containing one or more try-catch statements that have catch-all handlers and an optional return statement whose argument is a constant initializer.

A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.15-3-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.15-3-3

Summary

Handlers of a function-try-block implementation of a class constructor or destructor shall not reference non-static members from this class or its bases. (See page 162 of MISRA-CPP-2008 [64] .)

Implementation

There will be a report if a this expression has a chain of ancestors in the following order:

  • any sequence of expressions or statements,

  • a catch statement,

  • any sequence of declarations or statements except a function definition,

  • a try statement,

  • a constructor or a destructor definition.

Configuration

See generic service options.

Option statements
statements
-config=MP1.15-3-3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.15-3-3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP1.15-3-4

Summary

Each exception explicitly thrown in the code shall have a handler of a compatible type in all call paths that could lead to that point. (See page 163 of MISRA-CPP-2008 [64] .)

Description

The service reports any top-level function and destructor definition

  • if it has an uncaught throw; or

  • if it calls a function that does not have the nothrow property and does not have a catch-all for that call.

Notes:

  • A function has the property nothrow if it is declared with a noexcept-specifier to not throw exceptions or it is specified as nothrow -call_properties global configuration.

  • All calls to destructors are ignored as they are considered nothrow even if declared otherwise.

  • A function is top-level if it can be used as an entry point to the program.

  • A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

Imprecision

The following cases are reported as cautions if not handled with a catch-all block:

  • implicit and explicit calls to functions that do not have the nothrow property;

  • typeid expressions on polymorphic arguments;

  • dynamic_cast expressions.

This service depends upon the configuration of the following ancillary services: B.CALL.nothrow

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.15-3-4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.15-3-5

Summary

A class type exception shall always be caught by reference. (See page 163 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.15-3-6

Summary

Where multiple handlers are provided in a single try-catch statement or function-try-block for a derived class and some or all of its bases, the handlers shall be ordered most-derived to base class. (See page 165 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.15-3-7

Summary

Where multiple handlers are provided in a single try-catch statement or function-try-block, any ellipsis (catch-all) handler shall occur last. (See page 166 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.15-4-1

Summary

If a function is declared with an exception-specification, then all declarations of the same function (in other translation units) shall be declared with the same set of type-ids. (See page 167 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.16-0-1

Summary

#include directives in a file shall only be preceded by other preprocessor directives or comments. (See page 169 of MISRA-CPP-2008 [64] .)

Exceptions

The exception service configuration allows for some exceptions.

Configuration

See generic service options.

Option headers
headers
-config=MP1.16-0-1,headers={TAGS, HEADER_MATCHER},...

Specifies report tags for the #include directives.

The configuration’s content is a list of clauses specifying report tags for matching #include names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

HEADER_MATCHER:

the #include argument matcher including quotes or chevrons. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option exception
exception
-config=MP1.16-0-1,exception=EXCEPT,...

Specify allowed exceptions to this rule.

{EXCEPT,…}:

allowed exception to this rule. Accepted members are:

  • extern_C: constructs of the form extern "C" {...} are not considered to be code (for ‘C++’ rules);

  • extern_C_only: constructs of the form extern "C" are not considered to be code (for ‘C++’ rules); the following {…} may only contain preprocessor directives;

  • namespace_alias: constructs of the form namespace A = B are not considered to be code;

  • if_directive: directive subsections that are bounded by the #if, #else, #elif and #endif directives are considered as separate code chunks;


Rule MP1.16-0-2

Summary

Macros shall only be #define‘d or #undef‘d in the global namespace. (See page 170 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option macros
macros
-config=MP1.16-0-2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.16-0-3

Summary

#undef shall not be used. (See page 170 of MISRA-CPP-2008 [64] .)

Description

Note that, for this service, the report category is the directive name undef.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MP1.16-0-3,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=MP1.16-0-3,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=MP1.16-0-3,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MP1.16-0-4

Summary

Function-like macros shall not be defined. (See page 170 of MISRA-CPP-2008 [64] .)

Description

A function-like macro in the non-skipped compiled sources is considered replaceable by a function call if none of the following hold:

  • one of the macro invocation’s arguments is not expanded to an expression or it is expanded to an expression that cannot be interpreted as an rvalue (and hence cannot be used as a function call argument);

  • the macro body’s text contains special tokens (e.g. __LINE__, __FILE__, __COUNTER_, #, ##);

  • the macro is in a context that is not supported by the standard for including function calls;

  • the macro expands a non-replaceable macro;

  • the macro is used to emulate a template in C;

  • it is a system macro.

Imprecision

False positives are reported when criteria have not been precisely determined.

Criteria such as the trade-off between code size and execution speed are not considered.

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=MP1.16-0-4,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=MP1.16-0-4,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=MP1.16-0-4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.16-0-5

Summary

Arguments to a function-like macro shall not contain tokens that look like preprocessing directives. (See page 171 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option macros
macros
-config=MP1.16-0-5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.16-0-6

Summary

In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##. (See page 171 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option param_parentheses
param_parentheses
-config=MP1.16-0-6,param_parentheses=CONDS,...

Specify conditions when parameter parentheses are not required.

The configuration’s content is a short-circuit sequence of macro parameter parentheses.

CONDS:

conditions for parameter parentheses. Accepted forms are:

  • binary_op(): the parameter is an argument to a binary operator

  • unary_op(): the parameter is an argument to a unary operator

  • conditional_op(): the parameter is an argument to a conditional operator

  • pre(PRE_POST_EXPR): the tokens before the parameter must match PRE_POST_EXPR

  • post(PRE_POST_EXPR): the tokens after the parameter must match PRE_POST_EXPR

  • pre_post(PRE_POST_EXPR0,PRE_POST_EXPR1): the tokens before the parameter must match PRE_POST_EXPR0 and the tokens after the parameter must match PRE_POST_EXPR1

PRE_POST_EXPR

accepted forms are:

  • QSTRING: quoted token sequence

  • QSTRING||PRE_POST_EXPR: alternative quoted token sequences

Default:

-config=MP1.16-0-6,param_parentheses="pre('->'||'.')"

Option macros
macros
-config=MP1.16-0-6,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.16-0-7

Summary

Undefined macro identifiers shall not be used in #if or #elif preprocessor directives, except as operands to the defined operator. (See page 172 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.16-0-8

Summary

If the # token appears as the first token on a line, then it shall be immediately followed by a preprocessing token. (See page 172 of MISRA-CPP-2008 [64] .)

Description

Reports a preprocessing directive if:

  • it is not one of the preprocessing tokens specified in Section 16 of the C++03 standard [38];

  • it is a conditional directives that does not follow the pattern specified in Section 16 of the C++03 standard [38];

  • it is an #else or #endif directive that is followed by a character (ignoring any white space or comment tokens and before any newline character).

Notes:

  • any parsing error in the preprocessing code that is not excluded by conditional compilation will be reported by the service B.PARSER;

  • a preprocessing directive always begins with a # and the last token in the sequence is the first newline character that follows the first token in the sequence;

  • for this service, the report category is the directive name.

This service depends upon the configuration of the following ancillary services: STD.prepdirc

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.16-0-8,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MP1.16-1-1

Summary

The defined preprocessor operator shall only be used in one of the two standard forms. (See page 173 of MISRA-CPP-2008 [64] .)

Description

The defined preprocessor operator must use one of the two forms permitted by the standard (see Section 16.1 of the C++03 standard [38].

Additionally the defined token must not be generated by macro expansion during the expansion of a #if or #elif directive.

Configuration

See generic service options.

Rule MP1.16-1-2

Summary

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if or #ifdef directive to which they are related. (See page 173 of MISRA-CPP-2008 [64] .)

Description

Note that these constructs will be reported by the ECLAIR rule B.PARSER.

Configuration

See generic service options.

Rule MP1.16-2-1

Summary

The pre-processor shall only be used for file inclusion and include guards. (See page 174 of MISRA-CPP-2008 [64] .)

Description

Note that, for this service, the report category is the directive name.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=MP1.16-2-1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=MP1.16-2-1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=MP1.16-2-1,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MP1.16-2-2

Summary

C++ macros shall only be used for include guards, type qualifiers, or storage class specifiers. (See page 174 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option macros
macros
-config=MP1.16-2-2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.16-2-3

Summary

Include guards shall be provided. (See page 175 of MISRA-CPP-2008 [64] .)

Description

Note that this applies to any included file regardless of the file name extension.

Such a file must use one of the mechanisms: ifndef, ifdef and pragma where these are defined by the forms:

  • ifndef

#ifndef Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
#if !defined Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
  • ifdef

#ifdef Guard_Id
#else
#define Guard_Id ...
...
#endif
#if defined Guard_Id
#else
#define Guard_Id ...
...
#endif
  • pragma

#pragma first

It is also shown if the guard’s macro name is used elsewhere in any #define or #undef in the project.

There are no checks on the form or syntax of the macro name.

Configuration

See generic service options.

Option guard
guard
-config=MP1.16-2-3,guard={FILE, {CHECK,...}},...

Specify the allowed mechanisms to prevent the contents of a header file being included twice using advanced features.

The configuration’s content is an ordered list of file selectors with conditions; the conditions in the first clause whose file selector matches the file are checked.

FILE:

a -file_tag identifier or a matcher expression used to select the files.

CHECK

Accepted forms are:

  • mechanism(MECHANISM[||MECHANISM]*): the guard’s mechanism

  • guard(GUARD): the file name replacer REPLACER (see the -replacer global configuration). The input provided to the replacer is the canonical pathname of the guarded file; the macro name must match exactly, or must match the regular expression defined by FMT

  • comment(COMMENT_MATCHER): it will be reported if there is no matching comment following the #endif

  • reuse(REUSE_TAG): tag indicating if what reuse of the macro name should be reported

  • regex(): the replaced name is a regular expression that must match the macro guard name

REUSE_TAG

accepted forms are:

  • all_code: it is reported if the same guard identifier is reused for an identifier anywhere in the project code

  • all_defined: it is reported if the same guard identifier is redefined or undefined anywhere in the project

  • all_guards_in_unit: it is reported if the same guard identifier is used for more than one header file in the translation unit

  • all_guards_in_project: it is reported if the same guard identifier is used for more than one header file in the project

MECHANISM

accepted forms are:

  • any: any mechanism

  • ifndef: the guard mechanism using #ifndef Guard_Id or if !defined Guard_Id

  • ifdef: the mechanism using #if defined Guard_Id

  • pragma: the mechanism #pragma once

Default:

-config=MP1.16-2-3,guard={^.*$,
    {"mechanism(any)",
      "reuse(all_defined)"}}

Option directives
directives
-config=MP1.16-2-3,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MP1.16-2-4

Summary

The ', ", /* or // characters shall not occur in a header file name. (See page 175 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MP1.16-2-4,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MP1.16-2-4,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MP1.16-2-5

Summary

The \ character should not occur in a header file name. (See page 176 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MP1.16-2-5,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MP1.16-2-5,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MP1.16-2-6

Summary

The #include directive shall be followed by either a <filename> or "filename" sequence. (See page 176 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MP1.16-2-6,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MP1.16-2-6,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MP1.16-3-1

Summary

There shall be at most one occurrence of the # or ## operators in a single macro definition. (See page 176 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option macros
macros
-config=MP1.16-3-1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.16-3-2

Summary

The # and ## operators should not be used. (See page 177 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Option macros
macros
-config=MP1.16-3-2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.16-6-1

Summary

All uses of the #pragma directive shall be documented. (See page 177 of MISRA-CPP-2008 [64] .)

Description

Notes:

  • the STD.pragmdir behavior service configuration that has an associated -doc can be used to specify the documentation;

  • for each #pragma directive, the report will show a sample use with a summary indicating the total number of uses; the number of samples shown can be changed using the behavior_sampling service configuration.

This service depends upon the configuration of the following ancillary services: STD.pragmdir

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP1.16-6-1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option sample_reports
sample_reports
-config=MP1.16-6-1,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option behavior_sampling
behavior_sampling
-config=MP1.16-6-1,behavior_sampling={SERVICE, MAX},...

Specify sample size for matching ancillary service.

The configuration’s content is a set of ancillary service matchers with sample size.

SERVICE:

a service matcher used to select the ancillary services.

MAX:

unlimited or the maximum number of samples to be shown.


Rule MP1.17-0-1

Summary

Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefined. (See page 177 of MISRA-CPP-2008 [64] .)

Description

The reserved identifiers are defined to include all the following:

  • identifiers that are reserved by the C++03 standard [38];

  • identifiers that are reserved by the standard used by the translation unit;

  • identifiers that are reserved for future library directions.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C++ language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+=
   {my_lib, "c++", 2022, "c++", "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)",
      "decl(namespace(name(mylib)))"}

Then with the service configuration line

-config=MP1.17-0-1,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MP1.17-0-1,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MP1.17-0-1,reserved_standard="std()"

Option macros
macros
-config=MP1.17-0-1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=MP1.17-0-1,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.17-0-2

Summary

The names of standard library macros and objects shall not be reused. (See page 178 of MISRA-CPP-2008 [64] .)

Description

The standards checked are

  • the C++03 standard [38];

  • the standard used by the translation unit.

The reserved identifiers are all macro or object names that are reserved for current or future use by one of the standards.

Note that all namespace and tag qualifiers are considered relevant.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C++ language with reserved identifiers mylib_var and mylib_fun:

-+stdlib=my_lib
-+stdlib_description+=
   {my_lib, "c++", 2022, "c++", "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_var)", variable, always},
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)",
      "decl(namespace(name(mylib)))"}

Then with the service configuration line

-config=MP1.17-0-2,reserved_standard+="my_lib"

other declarations using the reserved identifiers mylib_var and mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MP1.17-0-2,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MP1.17-0-2,reserved_standard="std()"

Option declarations
declarations
-config=MP1.17-0-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.17-0-3

Summary

The names of standard library functions shall not be overridden. (See page 178 of MISRA-CPP-2008 [64] .)

Description

The standards checked are:

  • the C++03 standard [38];

  • the standard used by the translation unit.

Note that any namespace qualifiers are considered relevant.

To specify other libraries and their reserved identifiers, use the -stdlib and -stdlib_description global configurations to specify the library name with other information about the library and -stdlib_reserved global configuration to define the reserved identifiers within the library. For example, the following the configuration lines specify an additional library my_lib for the C++ language with reserved function identifier mylib_fun:

-+stdlib=my_lib
-+stdlib_description+=
   {my_lib, "c++", 2022, "c++", "my library", "project library"}
-+stdlib_reserved=
   {my_lib, "mylib.h", "name(mylib_fun)", "function(0)",
      "decl(namespace(name(mylib)))"}

Then with the service configuration line

-config=MP1.17-0-3,reserved_standard+="my_lib"

other function declarations that override mylib_fun will be reported.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=MP1.17-0-3,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=MP1.17-0-3,reserved_standard="std()"

Option declarations
declarations
-config=MP1.17-0-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.17-0-4

Summary

All library code shall conform to MISRA C++. (See page 178 of MISRA-CPP-2008 [64] .)

Description

Hence, any library that is not analyzed by ECLAIR using the same enabled rules as the user code is reported.

Configuration

See generic service options.

Rule MP1.17-0-5

Summary

The setjmp macro and the longjmp function shall not be used. (See page 179 of MISRA-CPP-2008 [64] .)

Description

Hence, there must be no use of the macro setjmp defined in csetjmp and the function longjmp declared in csetjmp.

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.17-0-5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP1.17-0-5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.18-0-1

Summary

The C library shall not be used. (See page 179 of MISRA-CPP-2008 [64] .)

Configuration

See generic service options.

Rule MP1.18-0-2

Summary

The library functions atof, atoi and atol from library <cstdlib> shall not be used. (See page 179 of MISRA-CPP-2008 [64] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.18-0-2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.18-0-3

Summary

The library functions abort, exit, getenv and system from library <cstdlib> shall not be used. (See page 180 of MISRA-CPP-2008 [64] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MP1.18-0-3,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MP1.18-0-3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.18-0-4

Summary

The time handling functions of library <ctime> shall not be used. (See page 180 of MISRA-CPP-2008 [64] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.18-0-4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.18-0-5

Summary

The unbounded functions of library <cstring> shall not be used. (See page 180 of MISRA-CPP-2008 [64] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.18-0-5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.18-2-1

Summary

The macro offsetof shall not be used. (See page 181 of MISRA-CPP-2008 [64] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.18-2-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP1.18-2-1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.18-4-1

Summary

Dynamic heap memory allocation shall not be used. (See page 181 of MISRA-CPP-2008 [64] .)

Description

Any use of functions that have the malloc property are reported

By default a function has the malloc property if:

  • the function has the attribute malloc;

  • it is one of the standard library functions malloc, calloc, realloc, aligned_alloc, free, strdup, operator new and operator delete.

Additional functions can be assigned the property malloc using the -call_properties global configuration. For example, the following configuration declares that any function whose identifier has the suffix _m has the property malloc:

-call_properties+={"decl(^.*_m\\(.*$)", {malloc}}

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=MP1.18-4-1,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=MP1.18-4-1,extra_statements={}

Option statements
statements
-config=MP1.18-4-1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP1.18-4-1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP1.18-7-1

Summary

The signal handling facilities of <csignal> shall not be used. (See page 182 of MISRA-CPP-2008 [64] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Exceptions

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.18-7-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP1.18-7-1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP1.19-3-1

Summary

The error indicator errno shall not be used. (See page 182 of MISRA-CPP-2008 [64] .)

Description

There must be no use of the macro errno defined in cerrno and the function perrno() declared in cstdio.

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MP1.19-3-1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MP1.19-3-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP1.27-0-1

Summary

The stream input/output library <cstdio> shall not be used. (See page 183 of MISRA-CPP-2008 [64] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP1.27-0-1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP1.27-0-1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


MISRA C++:2008 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C++:2008 coding standard [64].

For all rules, the mapping between the MISRA C++:2008 rules and the ECLAIR service identifiers is one-to-one and straightforward. e.g., MISRA C++:2008 Rule 0-1-1 maps to ECLAIR service MP1.0-1-1.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MP1 synopsis: supported MISRA C++:2008 rules

Id

Headline

Precision

MP1.0-1-1

A project shall not contain unreachable code

Best-effort

MP1.0-1-2

A project shall not contain infeasible paths

Best-effort

MP1.0-1-3

A project shall not contain unused variables

Exact

MP1.0-1-5

A project shall not contain unused type declarations

Exact

MP1.0-1-6

A project shall not contain instances of non-volatile variables being given values that are never subsequently used

Best-effort

MP1.0-1-7

The value returned by a function having a non-void return type that is not an overloaded operator shall always be used

Exact

MP1.0-1-8

All functions with void return type shall have external side effect(s)

Complete

MP1.0-1-9

There shall be no dead code

Best-effort

MP1.0-1-10

Every defined function shall be called at least once

Exact

MP1.0-1-11

There shall be no unused parameters (named or unnamed) in non-virtual functions

Exact

MP1.0-1-12

There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it

Exact

MP1.0-2-1

An object shall not be assigned to an overlapping object

Best-effort

MP1.0-3-1

Minimization of run-time failures shall be ensured by the use of at least one of:

  1. static analysis tools/techniques;

  2. dynamic analysis tools/techniques;

  3. explicit coding of checks to handle run-time faults.

Process

MP1.0-3-2

If a function generates error information, then that error information shall be tested

Process

MP1.0-4-1

Use of scaled-integer or fixed-point arithmetic shall be documented

Process

MP1.0-4-2

Use of floating-point arithmetic shall be documented

Process

MP1.0-4-3

Floating-point implementations shall comply with a defined floating-point standard

Process

MP1.1-0-1

All code shall conform to ISO/IEC 14882:2003 “The C++ Standard Incorporating Technical Corrigendum 1”

Exact

MP1.1-0-2

Multiple compilers shall only be used if they have a common, defined interface

Process

MP1.1-0-3

The implementation of integer division in the chosen compiler shall be determined and documented

Process

MP1.2-2-1

The character set and the corresponding encoding shall be documented

Process

MP1.2-3-1

Trigraphs shall not be used

Exact

MP1.2-5-1

Digraphs should not be used

Exact

MP1.2-7-1

The character sequence /* shall not be used within a C-style comment

Exact

MP1.2-7-2

Sections of code shall not be “commented out” using C-style comments

Heuristic

MP1.2-7-3

Sections of code should not be “commented out” using C++ comments

Heuristic

MP1.2-10-1

Different identifiers shall be typographically unambiguous

Exact

MP1.2-10-2

Identifiers declared in an inner scope shall not hide an identifier declared in an outer scope

Exact

MP1.2-10-3

A typedef name (including qualification, if any) shall be a unique identifier

Exact

MP1.2-10-4

A class, union or enum name (including qualification, if any) shall be a unique identifier

Exact

MP1.2-10-5

The identifier name of a non-member object or function with static storage duration should not be reused

Exact

MP1.2-10-6

If an identifier refers to a type, it shall not also refer to an object or a function in the same scope

Exact

MP1.2-13-1

Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used

Exact

MP1.2-13-2

Octal constants (other than zero) and octal escape sequences (other than “\0”) shall not be used

Exact

MP1.2-13-3

A U suffix shall be applied to all octal or hexadecimal integer literals of unsigned type

Exact

MP1.2-13-4

Literal suffixes shall be upper case

Exact

MP1.2-13-5

Narrow and wide string literals shall not be concatenated

Exact

MP1.3-1-1

It shall be possible to include any header file in multiple translation units without violating the One Definition Rule

Exact

MP1.3-1-2

Functions shall not be declared at block scope

Exact

MP1.3-1-3

When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization

Exact

MP1.3-2-1

All declarations of an object or function shall have compatible types

Exact

MP1.3-2-3

A type, object or function that is used in multiple translation units shall be declared in one and only one file

Exact

MP1.3-2-4

An identifier with external linkage shall have exactly one definition

Complete

MP1.3-3-1

Objects or functions with external linkage shall be declared in a header file

Exact

MP1.3-3-2

If a function has internal linkage then all re-declarations shall include the static storage class specifier

Exact

MP1.3-4-1

An identifier declared to be an object or type shall be defined in a block that minimizes its visibility

Complete

MP1.3-9-1

The types used for an object, a function return type, or a function parameter shall be token-for-token identical in all declarations and re-declarations

Exact

MP1.3-9-2

typedefs that indicate size and signedness should be used in place of the basic numerical types

Exact

MP1.3-9-3

The underlying bit representations of floating-point values shall not be used

Complete

MP1.4-5-1

Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator =, the logical operators &&, ||, !, the equality operators == and !=, the unary & operator, and the conditional operator

Exact

MP1.4-5-2

Expressions with type enum shall not be used as operands to built-in operators other than the subscript operator [ ], the assignment operator =, the equality operators == and !=, the unary & operator, and the relational operators <, <=, >, >=

Exact

MP1.4-5-3

Expressions with type (plain) char and wchar_t shall not be used as operands to built-in operators other than the assignment operator =, the equality operators == and !=, and the unary & operator

Exact

MP1.4-10-1

NULL shall not be used as an integer value

Exact

MP1.4-10-2

Literal zero (0) shall not be used as the null-pointer-constant

Exact

MP1.5-0-1

The value of an expression shall be the same under any order of evaluation that the standard permits

Safe

MP1.5-0-2

Limited dependence should be placed on C++ operator precedence rules in expressions

Exact

MP1.5-0-3

A cvalue expression shall not be implicitly converted to a different underlying type

Exact

MP1.5-0-4

An implicit integral conversion shall not change the signedness of the underlying type

Exact

MP1.5-0-5

There shall be no implicit floating-integral conversions

Exact

MP1.5-0-6

An implicit integral or floating-point conversion shall not reduce the size of the underlying type

Exact

MP1.5-0-7

There shall be no explicit floating-integral conversions of a cvalue expression

Exact

MP1.5-0-8

An explicit integral or floating-point conversion shall not increase the size of the underlying type of a cvalue expression

Exact

MP1.5-0-9

An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expression

Exact

MP1.5-0-10

If the bitwise operators ~ and << are applied to an operand with an underlying type of unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

Exact

MP1.5-0-11

The plain char type shall only be used for the storage and use of character values

Exact

MP1.5-0-12

signed char and unsigned char type shall only be used for the storage and use of numeric values

Exact

MP1.5-0-13

The condition of an if-statement and the condition of an iteration-statement shall have type bool

Exact

MP1.5-0-14

The first operand of a conditional-operator shall have type bool

Exact

MP1.5-0-15

Array indexing shall be the only form of pointer arithmetic

Complete

MP1.5-0-16

A pointer operand and any pointer resulting from pointer arithmetic using that operand shall both address elements of the same array

Best-effort

MP1.5-0-17

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Complete

MP1.5-0-18

>, >=, <, <= shall not be applied to objects of pointer type, except where they point to the same array

Complete

MP1.5-0-19

The declaration of objects shall contain no more than two levels of pointer indirection

Exact

MP1.5-0-20

Non-constant operands to a binary bitwise operator shall have the same underlying type

Exact

MP1.5-0-21

Bitwise operators shall only be applied to operands of unsigned underlying type

Exact

MP1.5-2-1

Each operand of a logical && or || shall be a postfix-expression

Exact

MP1.5-2-2

A pointer to a virtual base class shall only be cast to a pointer to a derived class by means of dynamic_cast

Exact

MP1.5-2-3

Casts from a base class to a derived class should not be performed on polymorphic types

Exact

MP1.5-2-4

C-style casts (other than void casts) and functional notation casts (other than explicit constructor calls) shall not be used

Exact

MP1.5-2-5

A cast shall not remove any const or volatile qualification from the type of a pointer or reference

Exact

MP1.5-2-6

A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type

Exact

MP1.5-2-7

An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly

Exact

MP1.5-2-8

An object with integer type or pointer to void type shall not be converted to an object with pointer type

Exact

MP1.5-2-9

A cast should not convert a pointer type to an integral type

Exact

MP1.5-2-10

The increment (++) and decrement (--) operators should not be mixed with other operators in an expression

Exact

MP1.5-2-11

The comma operator, && operator and the || operator shall not be overloaded

Exact

MP1.5-2-12

An identifier with array type passed as a function argument shall not decay to a pointer

Exact

MP1.5-3-1

Each operand of the ! operator, the logical && or the logical || operators shall have type bool

Exact

MP1.5-3-2

The unary minus operator shall not be applied to an expression whose underlying type is unsigned

Exact

MP1.5-3-3

The unary & operator shall not be overloaded

Exact

MP1.5-3-4

Evaluation of the operand to the sizeof operator shall not contain side effects

Exact

MP1.5-8-1

The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand

Complete

MP1.5-14-1

The right hand operand of a logical && or || operator shall not contain side effects

Safe

MP1.5-18-1

The comma operator shall not be used

Exact

MP1.5-19-1

Evaluation of constant unsigned integer expressions should not lead to wrap-around

Exact

MP1.6-2-1

Assignment operators shall not be used in sub-expressions

Exact

MP1.6-2-2

Floating-point expressions shall not be directly or indirectly tested for equality or inequality

Best-effort

MP1.6-2-3

Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment, provided that the first character following the null statement is a white-space character

Exact

MP1.6-3-1

The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement

Exact

MP1.6-4-1

An if ( condition ) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement

Exact

MP1.6-4-2

All if ... else if constructs shall be terminated with an else clause

Exact

MP1.6-4-3

A switch statement shall be a well-formed switch statement

Exact

MP1.6-4-4

A switch-label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Exact

MP1.6-4-5

An unconditional throw or break statement shall terminate every non-empty switch-clause

Exact

MP1.6-4-6

The final clause of a switch statement shall be the default-clause

Exact

MP1.6-4-7

The condition of a switch statement shall not have bool type

Exact

MP1.6-4-8

Every switch statement shall have at least one case-clause

Exact

MP1.6-5-1

A for loop shall contain a single loop-counter which shall not have floating type

Exact

MP1.6-5-2

If loop-counter is not modified by -- or ++, then, within condition, the loop-counter shall only be used as an operand to <=, <, > or >=

Exact

MP1.6-5-3

The loop-counter shall not be modified within condition or statement

Exact

MP1.6-5-4

The loop-counter shall be modified by one of: –, ++, -=n, or +=n; where n remains constant for the duration of the loop

Complete

MP1.6-5-5

A loop-control-variable other than the loop-counter shall not be modified within condition or expression

Complete

MP1.6-5-6

A loop-control-variable other than the loop-counter which is modified in statement shall have type bool

Exact

MP1.6-6-1

Any label referenced by a goto statement shall be declared in the same block, or in a block enclosing the goto statement

Exact

MP1.6-6-2

The goto statement shall jump to a label declared later in the same function body

Exact

MP1.6-6-3

The continue statement shall only be used within a well-formed for loop

Exact

MP1.6-6-4

For any iteration statement there shall be no more than one break or goto statement used for loop termination

Exact

MP1.6-6-5

A function shall have a single point of exit at the end of the function

Exact

MP1.7-1-1

A variable which is not modified shall be const qualified

Best-effort

MP1.7-1-2

A pointer or reference parameter in a function shall be declared as pointer to const or reference to const if the corresponding object is not modified

Best-effort

MP1.7-2-1

An expression with enum underlying type shall only have values corresponding to the enumerators of the enumeration

Exact

MP1.7-3-1

The global namespace shall only contain main, namespace declarations and extern "C" declarations

Exact

MP1.7-3-2

The identifier main shall not be used for a function other than the global function main

Exact

MP1.7-3-3

There shall be no unnamed namespaces in header files

Exact

MP1.7-3-4

using-directives shall not be used

Exact

MP1.7-3-5

Multiple declarations for an identifier in the same namespace shall not straddle a using-declaration for that identifier

Exact

MP1.7-3-6

using-directives and using-declarations (excluding class scope or function scope using-declarations) shall not be used in header files

Exact

MP1.7-4-1

All usage of assembler shall be documented

Process

MP1.7-4-2

Assembler instructions shall only be introduced using the asm declaration

Exact

MP1.7-4-3

Assembly language shall be encapsulated and isolated

Exact

MP1.7-5-1

A function shall not return a reference or a pointer to an automatic variable (including parameters), defined within the function

Safe

MP1.7-5-2

The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist

Safe

MP1.7-5-4

Functions should not call themselves, either directly or indirectly

Complete

MP1.8-0-1

An init-declarator-list or a member-declarator-list shall consist of a single init-declarator or member-declarator respectively

Exact

MP1.8-3-1

Parameters in an overriding virtual function shall either use the same default arguments as the function they override, or else shall not specify any default arguments

Exact

MP1.8-4-1

Functions shall not be defined using the ellipsis notation

Exact

MP1.8-4-2

The identifiers used for the parameters in a re-declaration of a function shall be identical to those in the declaration

Exact

MP1.8-4-3

All exit paths from a function with non-void return type shall have an explicit return statement with an expression

Exact

MP1.8-4-4

A function identifier shall either be used to call the function or it shall be preceded by &

Exact

MP1.8-5-1

All variables shall have a defined value before they are used

Safe

MP1.8-5-2

Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

Exact

MP1.8-5-3

In an enumerator list, the = construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized

Exact

MP1.9-3-3

If a member function can be made static then it shall be made static, otherwise if it can be made const then it shall be made const

Exact

MP1.9-5-1

Unions shall not be used

Exact

MP1.9-6-1

When the absolute positioning of bits representing a bit-field is required, then the behaviour and packing of bit-fields shall be documented

Process

MP1.9-6-2

Bit-fields shall be either bool type or an explicitly unsigned or signed integral type

Exact

MP1.9-6-3

Bit-fields shall not have enum type

Exact

MP1.9-6-4

Named bit-fields with signed integer type shall have a length of more than one bit

Exact

MP1.10-1-1

Classes should not be derived from virtual bases

Exact

MP1.10-1-2

A base class shall only be declared virtual if it is used in a diamond hierarchy

Exact

MP1.10-1-3

An accessible base class shall not be both virtual and non-virtual in the same hierarchy

Exact

MP1.10-3-1

There shall be no more than one definition of each virtual function on each path through the inheritance hierarchy

Exact

MP1.10-3-2

Each overriding virtual function shall be declared with the virtual keyword

Exact

MP1.10-3-3

A virtual function shall only be overridden by a pure virtual function if it is itself declared as pure virtual

Exact

MP1.11-0-1

Member data in non-POD class types shall be private

Exact

MP1.12-1-1

An object’s dynamic type shall not be used from the body of its constructor or destructor

Complete

MP1.12-1-2

All constructors of a class should explicitly call a constructor for all of its immediate base classes and all virtual base classes

Exact

MP1.12-1-3

All constructors that are callable with a single argument of fundamental type shall be declared explicit

Exact

MP1.12-8-2

The copy assignment operator shall be declared protected or private in an abstract class

Exact

MP1.14-5-1

A non-member generic function shall only be declared in a namespace that is not an associated namespace

Exact

MP1.14-6-1

In a class template with a dependent base, any name that may be found in that dependent base shall be referred to using a qualified-id or this->

Exact

MP1.14-7-1

All class templates, function templates, class template member functions and class template static members shall be instantiated at least once

Exact

MP1.14-8-1

Overloaded function templates shall not be explicitly specialized

Exact

MP1.15-0-2

An exception object should not have pointer type

Exact

MP1.15-0-3

Control shall not be transferred into a try or catch block using a goto or a switch statement

Exact

MP1.15-1-2

NULL shall not be thrown explicitly

Exact

MP1.15-1-3

An empty throw (throw;) shall only be used in the compound-statement of a catch handler

Exact

MP1.15-3-2

There should be at least one exception handler to catch all otherwise unhandled exceptions

Exact

MP1.15-3-3

Handlers of a function-try-block implementation of a class constructor or destructor shall not reference non-static members from this class or its bases

Exact

MP1.15-3-4

Each exception explicitly thrown in the code shall have a handler of a compatible type in all call paths that could lead to that point

Complete

MP1.15-3-5

A class type exception shall always be caught by reference

Exact

MP1.15-3-6

Where multiple handlers are provided in a single try-catch statement or function-try-block for a derived class and some or all of its bases, the handlers shall be ordered most-derived to base class

Exact

MP1.15-3-7

Where multiple handlers are provided in a single try-catch statement or function-try-block, any ellipsis (catch-all) handler shall occur last

Exact

MP1.15-4-1

If a function is declared with an exception-specification, then all declarations of the same function (in other translation units) shall be declared with the same set of type-ids

Exact

MP1.16-0-1

#include directives in a file shall only be preceded by other preprocessor directives or comments

Exact

MP1.16-0-2

Macros shall only be #define‘d or #undef‘d in the global namespace

Exact

MP1.16-0-3

#undef shall not be used

Exact

MP1.16-0-4

Function-like macros shall not be defined

Complete

MP1.16-0-5

Arguments to a function-like macro shall not contain tokens that look like preprocessing directives

Exact

MP1.16-0-6

In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##

Exact

MP1.16-0-7

Undefined macro identifiers shall not be used in #if or #elif preprocessor directives, except as operands to the defined operator

Exact

MP1.16-0-8

If the # token appears as the first token on a line, then it shall be immediately followed by a preprocessing token

Exact

MP1.16-1-1

The defined preprocessor operator shall only be used in one of the two standard forms

Exact

MP1.16-1-2

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if or #ifdef directive to which they are related

Exact

MP1.16-2-1

The pre-processor shall only be used for file inclusion and include guards

Exact

MP1.16-2-2

C++ macros shall only be used for include guards, type qualifiers, or storage class specifiers

Exact

MP1.16-2-3

Include guards shall be provided

Exact

MP1.16-2-4

The ', ", /* or // characters shall not occur in a header file name

Exact

MP1.16-2-5

The \ character should not occur in a header file name

Exact

MP1.16-2-6

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MP1.16-3-1

There shall be at most one occurrence of the # or ## operators in a single macro definition

Exact

MP1.16-3-2

The # and ## operators should not be used

Exact

MP1.16-6-1

All uses of the #pragma directive shall be documented

Process

MP1.17-0-1

Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefined

Exact

MP1.17-0-2

The names of standard library macros and objects shall not be reused

Exact

MP1.17-0-3

The names of standard library functions shall not be overridden

Exact

MP1.17-0-4

All library code shall conform to MISRA C++

Exact

MP1.17-0-5

The setjmp macro and the longjmp function shall not be used

Exact

MP1.18-0-1

The C library shall not be used

Exact

MP1.18-0-2

The library functions atof, atoi and atol from library <cstdlib> shall not be used

Exact

MP1.18-0-3

The library functions abort, exit, getenv and system from library <cstdlib> shall not be used

Exact

MP1.18-0-4

The time handling functions of library <ctime> shall not be used

Exact

MP1.18-0-5

The unbounded functions of library <cstring> shall not be used

Exact

MP1.18-2-1

The macro offsetof shall not be used

Exact

MP1.18-4-1

Dynamic heap memory allocation shall not be used

Process

MP1.18-7-1

The signal handling facilities of <csignal> shall not be used

Exact

MP1.19-3-1

The error indicator errno shall not be used

Exact

MP1.27-0-1

The stream input/output library <cstdio> shall not be used

Exact

MISRA C++:2008 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C++:2008 coding standard [64].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C++:2008 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

0-1-1
Required

no violation report for MP1.0-1-1

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

0-1-2
Required

no violation report for MP1.0-1-2

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

0-1-3
Required

no violation report for MP1.0-1-3

0-1-4
Required

conduct a manual review to ensure compliance to the guideline

0-1-5
Required

no violation report for MP1.0-1-5

0-1-6
Required

no violation report for MP1.0-1-6

after: when no other dead stores can be shown to exist, deviate for the possible false negatives as described in the service documentation

0-1-7
Required

no violation report for MP1.0-1-7

0-1-8
Required

no violation report or caution report for MP1.0-1-8 or B.CALL.noeffect

before: provide a complete and accurate configuration of the noeffect property for all the functions and function types that do not cause side effects.

0-1-9
Required

no violation report or caution report for MP1.0-1-9

after: when no other dead code can be proven to exist, deviate for the possible false negatives as described in the service documentation

0-1-10
Required

no violation report for MP1.0-1-10

0-1-11
Required

no violation report for MP1.0-1-11

0-1-12
Required

no violation report for MP1.0-1-12

0-2-1
Required

no violation report or caution report for MP1.0-2-1

after: assignments to or from objects created with some overlap in memory with another object should be checked

0-3-1
Document

no violation report for MP1.0-3-1

before: for each run-time failure category either choose an adequate minimization strategy or document in the source code a reason why it cannot happen; specify using document service configuration the position and format of the document

0-3-2
Required

no violation report for MP1.0-3-2

before: provide a complete and accurate configuration for calls not in the Standard Library that return error information

0-4-1
Document

no violation report for MP1.0-4-1

before: document in the source code any use of scaled-integer and fixed-point arithmetic; specify using the document service configuration the position and format of the document

0-4-2
Document

no violation report for MP1.0-4-2

before: document in the source code any use of floating-point arithmetic; specify using the document service configuration the position and format of the document document

0-4-3
Document

no violation report for MP1.0-4-3

before: document in the source code the floating-point standard used by the implementation; specify using document service configuration the position and format of the document

1-0-1
Required

no violation report for MP1.1-0-1

before: specify using the behavior configuration of the related ancillary services any deviations from the standard

1-0-2
Document

no violation report for MP1.1-0-2

before: check the interface standards for each compiler and/or language used by the source files and white-list using the compilers service configuration.

1-0-3
Document

no violation report for MP1.1-0-3

before: document the expected direction of rounding using the service configuration described in the service description

2-2-1
Document

no violation report for MP1.2-2-1

before: document each source, execution character set and the corresponding encoding using the behavior configuration of the related ancillary services

2-3-1
Required

no violation report for MP1.2-3-1

2-5-1
Advisory

no violation report for MP1.2-5-1

2-7-1
Required

no violation report for MP1.2-7-1

2-7-2
Required

no violation report for MP1.2-7-2

after: check for any residual unreported commented out code

2-7-3
Advisory

no violation report for MP1.2-7-3

after: check for any residual unreported commented out code

2-10-1
Required

no violation report for MP1.2-10-1

2-10-2
Required

no violation report for MP1.2-10-2

2-10-3
Required

no violation report for MP1.2-10-3

2-10-4
Required

no violation report for MP1.2-10-4

2-10-5
Advisory

no violation report for MP1.2-10-5

2-10-6
Required

no violation report for MP1.2-10-6

2-13-1
Required

no violation report for MP1.2-13-1

2-13-2
Required

no violation report for MP1.2-13-2

2-13-3
Required

no violation report for MP1.2-13-3

2-13-4
Required

no violation report for MP1.2-13-4

2-13-5
Required

no violation report for MP1.2-13-5

3-1-1
Required

no violation report for MP1.3-1-1

3-1-2
Required

no violation report for MP1.3-1-2

3-1-3
Required

no violation report for MP1.3-1-3

3-2-1
Required

no violation report for MP1.3-2-1

3-2-2
Required

conduct a manual review to ensure compliance to the guideline

3-2-3
Required

no violation report for MP1.3-2-3

3-2-4
Required

no violation report or caution report for MP1.3-2-4

3-3-1
Required

no violation report for MP1.3-3-1

3-3-2
Required

no violation report for MP1.3-3-2

3-4-1
Required

no violation report or caution report for MP1.3-4-1

3-9-1
Required

no violation report for MP1.3-9-1

3-9-2
Advisory

no violation report for MP1.3-9-2

3-9-3
Required

no violation report for MP1.3-9-3

4-5-1
Required

no violation report for MP1.4-5-1

4-5-2
Required

no violation report for MP1.4-5-2

4-5-3
Required

no violation report for MP1.4-5-3

4-10-1
Required

no violation report for MP1.4-10-1

4-10-2
Required

no violation report for MP1.4-10-2

5-0-1
Required

no violation report or caution report for MP1.5-0-1

5-0-2
Advisory

no violation report for MP1.5-0-2

5-0-3
Required

no violation report for MP1.5-0-3

5-0-4
Required

no violation report for MP1.5-0-4

5-0-5
Required

no violation report for MP1.5-0-5

5-0-6
Required

no violation report for MP1.5-0-6

5-0-7
Required

no violation report for MP1.5-0-7

5-0-8
Required

no violation report for MP1.5-0-8

5-0-9
Required

no violation report for MP1.5-0-9

5-0-10
Required

no violation report for MP1.5-0-10

5-0-11
Required

no violation report for MP1.5-0-11

5-0-12
Required

no violation report for MP1.5-0-12

5-0-13
Required

no violation report for MP1.5-0-13

5-0-14
Required

no violation report for MP1.5-0-14

5-0-15
Required

no violation report or caution report for MP1.5-0-15

5-0-16
Required

no violation report or caution report for MP1.5-0-16

after: pointers subject to addition or subtraction should be checked

5-0-17
Required

no violation report or caution report for MP1.5-0-17

5-0-18
Required

no violation report or caution report for MP1.5-0-18

5-0-19
Required

no violation report for MP1.5-0-19

5-0-20
Required

no violation report for MP1.5-0-20

5-0-21
Required

no violation report for MP1.5-0-21

5-2-1
Required

no violation report for MP1.5-2-1

5-2-2
Required

no violation report for MP1.5-2-2

5-2-3
Advisory

no violation report for MP1.5-2-3

5-2-4
Required

no violation report for MP1.5-2-4

5-2-5
Required

no violation report for MP1.5-2-5

5-2-6
Required

no violation report for MP1.5-2-6

5-2-7
Required

no violation report for MP1.5-2-7

5-2-8
Required

no violation report for MP1.5-2-8

5-2-9
Advisory

no violation report for MP1.5-2-9

5-2-10
Advisory

no violation report for MP1.5-2-10

5-2-11
Required

no violation report for MP1.5-2-11

5-2-12
Required

no violation report for MP1.5-2-12

5-3-1
Required

no violation report for MP1.5-3-1

5-3-2
Required

no violation report for MP1.5-3-2

5-3-3
Required

no violation report for MP1.5-3-3

5-3-4
Required

no violation report for MP1.5-3-4

5-8-1
Required

no violation report or caution report for MP1.5-8-1

5-14-1
Required

no violation report or caution report for MP1.5-14-1

5-17-1
Required

conduct a manual review to ensure compliance to the guideline

5-18-1
Required

no violation report for MP1.5-18-1

5-19-1
Advisory

no violation report for MP1.5-19-1

6-2-1
Required

no violation report for MP1.6-2-1

6-2-2
Required

no violation report for MP1.6-2-2

after: conduct a manual review of every equality or disequality test that could indirectly involve floating-point values

6-2-3
Required

no violation report for MP1.6-2-3

6-3-1
Required

no violation report for MP1.6-3-1

6-4-1
Required

no violation report for MP1.6-4-1

6-4-2
Required

no violation report for MP1.6-4-2

after: check the content of any explanatory comment

6-4-3
Required

no violation report for MP1.6-4-3

6-4-4
Required

no violation report for MP1.6-4-4

6-4-5
Required

no violation report for MP1.6-4-5

6-4-6
Required

no violation report for MP1.6-4-6

6-4-7
Required

no violation report for MP1.6-4-7

6-4-8
Required

no violation report for MP1.6-4-8

6-5-1
Required

no violation report for MP1.6-5-1

6-5-2
Required

no caution or violation for this rule and rule 6-5-1

6-5-3
Required

no caution or violation for this rule and rule 6-5-1

6-5-4
Required

no caution or violation for this rule and rule 6-5-1

6-5-5
Required

no caution or violation for this rule and rule 6-5-1

6-5-6
Required

no caution or violation for this rule and rule 6-5-1

6-6-1
Required

no violation report for MP1.6-6-1

6-6-2
Required

no violation report for MP1.6-6-2

6-6-3
Required

no violation report for MP1.6-6-3

6-6-4
Required

no violation report for MP1.6-6-4

6-6-5
Required

no violation report for MP1.6-6-5

7-1-1
Required

no violation report for MP1.7-1-1

after: check each non-const pointer with program scope for compliance

7-1-2
Required

no violation report for MP1.7-1-2

after: check each non-const pointer with program scope for compliance

7-2-1
Required

no violation report for MP1.7-2-1

7-3-1
Required

no violation report for MP1.7-3-1

7-3-2
Required

no violation report for MP1.7-3-2

7-3-3
Required

no violation report for MP1.7-3-3

7-3-4
Required

no violation report for MP1.7-3-4

7-3-5
Required

no violation report for MP1.7-3-5

7-3-6
Required

no violation report for MP1.7-3-6

7-4-1
Document

no violation report for MP1.7-4-1

before: ensure that every use of assembler and its interface with C is documented

7-4-2
Required

no violation report for MP1.7-4-2

7-4-3
Required

no violation report for MP1.7-4-3

before: check that the name, and any documentation, of the encapsulating macro or function makes the intent clear

7-5-1
Required

no violation report or caution report for MP1.7-5-1

7-5-2
Required

no violation report or caution report for MP1.7-5-2

7-5-3
Required

conduct a manual review to ensure compliance to the guideline

7-5-4
Advisory

no violation report or caution report for MP1.7-5-4

8-0-1
Required

no violation report for MP1.8-0-1

8-3-1
Required

no violation report for MP1.8-3-1

8-4-1
Required

no violation report for MP1.8-4-1

8-4-2
Required

no violation report for MP1.8-4-2

8-4-3
Required

no violation report for MP1.8-4-3

8-4-4
Required

no violation report for MP1.8-4-4

8-5-1
Required

no violation report or caution report for MP1.8-5-1

after: manually recheck use of variables in the scope of any backward or sideways jumps caused by (possibly indirect) goto statements

8-5-2
Required

no violation report for MP1.8-5-2

8-5-3
Required

no violation report for MP1.8-5-3

9-3-1
Required

conduct a manual review to ensure compliance to the guideline

9-3-2
Required

conduct a manual review to ensure compliance to the guideline

9-3-3
Required

no violation report for MP1.9-3-3

9-5-1
Required

no violation report for MP1.9-5-1

9-6-1
Document

no violation report for MP1.9-6-1

before: document each class, struct or union that contains a bit-field using the behavior configuration of the related ancillary services

9-6-2
Required

no violation report for MP1.9-6-2

9-6-3
Required

no violation report for MP1.9-6-3

9-6-4
Required

no violation report for MP1.9-6-4

10-1-1
Advisory

no violation report for MP1.10-1-1

10-1-2
Required

no violation report for MP1.10-1-2

10-1-3
Required

no violation report for MP1.10-1-3

10-2-1
Advisory

conduct a manual review to ensure compliance to the guideline

10-3-1
Required

no violation report for MP1.10-3-1

10-3-2
Required

no violation report for MP1.10-3-2

10-3-3
Required

no violation report for MP1.10-3-3

11-0-1
Required

no violation report for MP1.11-0-1

12-1-1
Required

no violation report or caution report for MP1.12-1-1

12-1-2
Advisory

no violation report for MP1.12-1-2

12-1-3
Required

no violation report for MP1.12-1-3

12-8-1
Required

conduct a manual review to ensure compliance to the guideline

12-8-2
Required

no violation report for MP1.12-8-2

14-5-1
Required

no violation report for MP1.14-5-1

14-5-2
Required

conduct a manual review to ensure compliance to the guideline

14-5-3
Required

conduct a manual review to ensure compliance to the guideline

14-6-1
Required

no violation report for MP1.14-6-1

14-6-2
Required

conduct a manual review to ensure compliance to the guideline

14-7-1
Required

no violation report for MP1.14-7-1

14-7-2
Required

conduct a manual review to ensure compliance to the guideline

14-7-3
Required

conduct a manual review to ensure compliance to the guideline

14-8-1
Required

no violation report for MP1.14-8-1

14-8-2
Advisory

conduct a manual review to ensure compliance to the guideline

15-0-1
Document

conduct a manual review to ensure compliance to the guideline

15-0-2
Advisory

no violation report for MP1.15-0-2

15-0-3
Required

no violation report for MP1.15-0-3

15-1-1
Required

conduct a manual review to ensure compliance to the guideline

15-1-2
Required

no violation report for MP1.15-1-2

15-1-3
Required

no violation report for MP1.15-1-3

15-3-1
Required

conduct a manual review to ensure compliance to the guideline

15-3-2
Advisory

no violation report for MP1.15-3-2

15-3-3
Required

no violation report for MP1.15-3-3

15-3-4
Required

no violation report or caution report for MP1.15-3-4 or B.CALL.nothrow

before: provide a complete and accurate configuration of the nothrow property for all the functions and function types that do not throw exceptions

15-3-5
Required

no violation report for MP1.15-3-5

15-3-6
Required

no violation report for MP1.15-3-6

15-3-7
Required

no violation report for MP1.15-3-7

15-4-1
Required

no violation report for MP1.15-4-1

15-5-1
Required

conduct a manual review to ensure compliance to the guideline

15-5-2
Required

conduct a manual review to ensure compliance to the guideline

15-5-3
Required

conduct a manual review to ensure compliance to the guideline

16-0-1
Required

no violation report for MP1.16-0-1

16-0-2
Required

no violation report for MP1.16-0-2

16-0-3
Required

no violation report for MP1.16-0-3

16-0-4
Required

no violation report for MP1.16-0-4

16-0-5
Required

no violation report for MP1.16-0-5

16-0-6
Required

no violation report for MP1.16-0-6

16-0-7
Required

no violation report for MP1.16-0-7

16-0-8
Required

no violation report for MP1.16-0-8

16-1-1
Required

no violation report for MP1.16-1-1

16-1-2
Required

no violation report for MP1.16-1-2

16-2-1
Required

no violation report for MP1.16-2-1

16-2-2
Required

no violation report for MP1.16-2-2

16-2-3
Required

no violation report for MP1.16-2-3

16-2-4
Required

no violation report for MP1.16-2-4

16-2-5
Advisory

no violation report for MP1.16-2-5

16-2-6
Required

no violation report for MP1.16-2-6

16-3-1
Required

no violation report for MP1.16-3-1

16-3-2
Advisory

no violation report for MP1.16-3-2

16-6-1
Document

no violation report for MP1.16-6-1

before: document each #pragma directive in the non-skipped compiled file contents using the behavior configuration of the related ancillary services

17-0-1
Required

no violation report for MP1.17-0-1

17-0-2
Required

no violation report for MP1.17-0-2

17-0-3
Required

no violation report for MP1.17-0-3

17-0-4
Document

no violation report for MP1.17-0-4

17-0-5
Required

no violation report for MP1.17-0-5

18-0-1
Required

no violation report for MP1.18-0-1

18-0-2
Required

no violation report for MP1.18-0-2

18-0-3
Required

no violation report for MP1.18-0-3

18-0-4
Required

no violation report for MP1.18-0-4

18-0-5
Required

no violation report for MP1.18-0-5

18-2-1
Required

no violation report for MP1.18-2-1

18-4-1
Required

no violation report for MP1.18-4-1

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

18-7-1
Required

no violation report for MP1.18-7-1

19-3-1
Required

no violation report for MP1.19-3-1

27-0-1
Required

no violation report for MP1.27-0-1

The MISRA C++:2023 Coding Rules

For the MISRA C++:2023 [56] coding rules, the exact definition takes into account all clarifications published the MISRA information and discussion forum. Note that for each of the supported MISRA C++:2023 rules, the identifier for the corresponding ECLAIR service is obtained by adding the prefix MP2., thereby obtaining, for example: MP2.0.1.1, MP2.4.1.2, MP2.16.5.1, …

Note that the page numbers included in the references to [56] in the ECLAIR service summaries are for the PDF version of [56] .

Directive MP2.0.3.1

Summary

Floating-point arithmetic should be used appropriately. (See page 35 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.0.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.0.3.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Directive MP2.5.7.2

Summary

Sections of code should not be “commented out”. (See page 42 of MISRA-CPP-2023 [56] .)

Description

Any use of #if 0 is reported as a caution.

Note that, by default, doxygen comments are ignored; this can be changed using the ignored_comments service configuration. For example, with the following configure line, all comments will be checked:

-doc="Prevent doxygen comments from being ignored."
-config=MP2.5.7.2,+ignored_comments="none()"

Implementation

A comment is non-compliant if it looks like code. That is, a comment is reported if a statistical measure (based on the total token length and number of keywords and operators) is exceeded.

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

It is not possible to precisely differentiate code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

/* This is a comment */

Configuration

See generic service options.

Option comments
comments
-config=MP2.5.7.2,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=MP2.5.7.2,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=MP2.5.7.2,code_lines=0

Option ignored_comments
ignored_comments
-config=MP2.5.7.2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MP2.5.7.2,ignored_comments=__doxygen_comments

Rule MP2.0.0.1

Summary

A function shall not contain unreachable statements. (See page 20 of MISRA-CPP-2023 [56] .)

Description

The rule reports unreachable statements where:

  • both left and right operands of a reachable binary logical operator are considered reachable and;

  • all three operands of a reachable conditional operator (?:) are considered reachable; and

  • the alternative paths from the condition of a selection-statement or an iteration-statement are all considered reachable, except when the condition is a constant expression, in which case only the paths selected by the condition are considered reachable; and

  • a statement following a call to a function declared [[noreturn]]; and

  • catch-handlers

    • if a try compound-statement of a (function-)try-block does not contain a reachable, potentially- throwing statement,

    • a catch-handler that appears after a more generic handler of the same try-block is not reachable.

Notes:

  • If the context of a deliberately unreachable statement or expression is a selection or iteration statement and the unreachability is due to its condition or guard, then the report can be tagged using the statements service configuration where the matcher targets the context (see below for an example).

Examples:

With the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library entry points not necessarily have to be referenced."
-config=MP2.0.0.1,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

With the configuration lines:

-doc="constexpr if statements are expected to have unreachable branches."
-config=MP2.0.0.1,+statements={known,"node(if_stmt)&&kind(constexpr))"}

reports for unreachable nodes in the false branch of a constexpr if statement will be tagged known.

Imprecision

False negatives for noreturn calls in try blocks.

Configuration

See generic service options.

Option ignored_stmts
ignored_stmts
-config=MP2.0.0.1,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Option statements
statements
-config=MP2.0.0.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option diagnostics
diagnostics
-config=MP2.0.0.1,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MP2.0.0.2

Summary

Controlling expressions should not be invariant. (See page 22 of MISRA-CPP-2023 [56] .)

Description

An expression is taken to be controlling if it is:

  • the left hand operand of the logical AND (&&) and logical OR (||) operators;

  • the condition part of the :? operator;

  • the condition part of an if, do, for, while or switch statement.

Notes:

  • expressions in a compile-time constant context are not reported;

  • if the condition for a while statement is the Boolean constant for true, then it is ignored;

  • if the condition for a do statement is the Boolean constant for false then it is also ignored;

  • observe that in the above allowed loop idioms, we have deliberately chosen to limit the controlling expressions of while-true and do-while-false loop idioms to Boolean constants. This is because the Exceptions on the MISRA C document allow any dowhile (evaluating either to a true value for Exception 1 and a false value for Exception 2);

  • other loop idioms can be added using the -loop_idioms global configuration;

  • in addition, reports for any statements with controlling expressions that have fixed values can be tagged using the statements service configuration.

Implementation

The rule only reports an expression if it can be detected that the expression will always have the same value.

Imprecision

False negatives are present because, in general, the fixed values of constant expressions may not be statically known.

Configuration

See generic service options.

Option statements
statements
-config=MP2.0.0.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MP2.0.1.1

Summary

A value should not be unnecessarily written to a local object. (See page 24 of MISRA-CPP-2023 [56] .)

Imprecision

All reports are cautions.

False negatives are present due to the undecidability of the guideline.

Configuration

See generic service options.

Rule MP2.0.1.2

Summary

The value returned by a function shall be used. (See page 28 of MISRA-CPP-2023 [56] .)

Description

Notes:

  • calls to a non-void function whose return value is ignored are reported;

  • calls where the return value is cast to void are regarded as uses and only reported in the summary.

  • all calls are included in a statistical summary for the program and the called function;

  • the summary provides:

    • the number of calls to the function,

    • the number of times the return value is ignored but this was expected,

    • the number of times the return value is cast to void and

    • the number of times it is ignored unexpectedly;

  • the number of samples shown can be changed using the use_samples service configuration.

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=MP2.0.1.2,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option use_samples
use_samples
-config=MP2.0.1.2,use_samples={TAG, MAX},...

Specify the maximum number of samples to be output.

The configuration’s content is a list of return use tags (ignored, to_void, used) with the maximum number of samples to be output; if a use tag is not specified, then all calls matching the tag will be shown as violations.

TAG:

tag indicating the return use. Accepted values are:

  • used: return value is used;

  • ignored: return value is ignored;

  • to_void: return value is cast to void;

MAX:

maximum number of samples to be shown. It must be an integer greater than or equal to -1.

Default:

-config=MP2.0.1.2,use_samples={ignored, -1}, {to_void, 1}, {used, 1}

Option calls
calls
-config=MP2.0.1.2,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=MP2.0.1.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.0.2.1

Summary

Variables with limited visibility should be used at least once. (See page 28 of MISRA-CPP-2023 [56] .)

Description

A variable has limited visibility if:

  • it is not a function parameter, and

  • it has internal linkage or no linkage.

A variable is used if:

  • it is part of an id-expression, or;

  • it has class type and has a user-provided constructor or destructor.

Exceptions

A variable that:

  • has at least one declaration with the [[maybe_unused]] attribute

  • is constant and declared at namespace scope in a header file.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.0.2.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP2.0.2.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP2.0.2.2

Summary

A named function parameter shall be used at least once. (See page 30 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.0.2.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.0.2.4

Summary

Functions with limited visibility should be used at least once. (See page 34 of MISRA-CPP-2023 [56] .)

Description

Notes:

  • Declarations can be hidden using the declarations service configuration; in particular, to hide declarations in public API files by:

    • exploiting the globally defined decl_selector __public_api_decls;

    • and modifying, as needed, the default set of public API files (which, by default, includes all system header files) using the -file_tag and the -public_files global configurations.

For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

the configuration line

-doc="Library functions not necessarily have to be referenced."
-config=MP2.0.2.4,+declarations={safe,"loc(top(public()))"}

deviates all reports in the public files including any file whose name matches the regular expression ^my_public_header.h$.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.0.2.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=MP2.0.2.4,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP2.4.1.1

Summary

A program shall conform to ISO/IEC 14882:2017 (C++17). (See page 37 of MISRA-CPP-2023 [56] .)

Imprecision

False negatives may be present due incomplete semantic information

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.extident STD.flexaray STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.prepdirc STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP2.4.1.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=MP2.4.1.1,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=MP2.4.1.1,standards=c++17

Rule MP2.4.1.2

Summary

Deprecated features should not be used. (See page 38 of MISRA-CPP-2023 [56] .)

Description

The behavior configuration of the related ancillary services that has an associated -doc can be used to specify the behavior and documentation. The service reports all instances of deprecated behaviours.

This service depends upon the configuration of the following ancillary services: STD.throwexc STD.strstrea STD.defalloc STD.storgitr STD.tempbuff STD.metatype STD.itertype STD.codecvt STD.wstrconv STD.cnstexpr STD.impldefn STD.cppheads STD.spunique STD.deprdiag STD.funcbind

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP2.4.1.2,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MP2.4.1.3

Summary

There shall be no occurrence of undefined or critical unspecified behaviour. (See page 38 of MISRA-CPP-2023 [56] .)

Description

The ancilliary services used to implement this service have been designed for C and may be inapplicable for C++.

The behavior configuration of the related ancillary services that has an associated -doc can be used to specify the behavior and documentation.

No guarantees are made with respect to critical unspecified behaviours.

Imprecision

Cautions are reported when the behavior item is undecidable.

When the undefined or critical unspecified behavior item is undecidable, the related ancillary service will report possible non-compliance as a caution.

False negatives are possible for those behaviors not otherwise listed.

This service depends upon the configuration of the following ancillary services: STD.anonstct STD.charescp STD.charset STD.charxwde STD.defined STD.encderor STD.eofnl STD.hostmain STD.iddiflkg STD.intnlobj STD.linedir STD.nonstdc STD.stdcctxt STD.stdcprag

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP2.4.1.3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MP2.4.6.1

Summary

Operations on a memory location shall be sequenced appropriately. (See page 39 of MISRA-CPP-2023 [56] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a call has been declared to have an impact property const, pure or noeffect, it may result in a change to the value of one of its arguments or to the value of a global variable.

  • For C++17 and later C++ standards, the evaluation of the right-hand side of an assignment is sequenced before the evaluation of the left-hand side

  • The -call_properties global configuration can be used to specify a call’s impact property.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has impact property pure, implying that it has no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

False negatives are present due to the undecidability of the guideline.

Configuration

See generic service options.

Option effects
effects
-config=MP2.4.6.1,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MP2.5.0.1

Summary

Trigraph-like sequences should not be used. (See page 41 of MISRA-CPP-2023 [56] .)

Description

Note that trigraphs-like sequences are denoted by ??=, ??(, ??<, ??/, ??), ??>, ??', ??|, and ??-.

Configuration

See generic service options.

Rule MP2.5.7.1

Summary

The character sequence /* shall not be used within a C-style comment. (See page 41 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option comments
comments
-config=MP2.5.7.1,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=MP2.5.7.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP2.5.7.3

Summary

Line-splicing shall not be used in // comments. (See page 43 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option comments
comments
-config=MP2.5.7.3,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP2.5.10.1

Summary

User-defined identifiers shall have an appropriate form. (See page 44 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=MP2.5.10.1,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=MP2.5.10.1,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=MP2.5.10.1,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=MP2.5.10.1,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=MP2.5.10.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.5.10.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=MP2.5.10.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP2.5.13.1

Summary

Within character literals and non raw-string literals, \ shall only be used to form a defined escape sequence or universal character name. (See page 46 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.5.13.2

Summary

Octal escape sequences, hexadecimal escape sequences and universal character names shall be terminated. (See page 46 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option literals
literals
-config=MP2.5.13.2,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP2.5.13.3

Summary

Octal constants shall not be used. (See page 47 of MISRA-CPP-2023 [56] .)

Exceptions

The integer constant 0 is allowed..

Configuration

See generic service options.

Option literals
literals
-config=MP2.5.13.3,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP2.5.13.4

Summary

Unsigned integer literals shall be appropriately suffixed. (See page 47 of MISRA-CPP-2023 [56] .)

Description

Notes:

  • the rule applies to code after preprocessing;

  • the rule does not apply to user-defined-integer-literals;

  • the context in which the constant is used is not relevant;

  • the inferred type for the integer constants is as specified in the table on page 44 of the C++17 standard [42].

Configuration

See generic service options.

Option literals
literals
-config=MP2.5.13.4,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP2.5.13.5

Summary

The lowercase form of L shall not be used as the first character in a literal suffix. (See page 48 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option literals
literals
-config=MP2.5.13.5,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP2.5.13.6

Summary

An integer-literal of type long long shall not use a single L or l in any suffix. (See page 49 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option literals
literals
-config=MP2.5.13.6,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule MP2.5.13.7

Summary

String literals with different encoding prefixes shall not be concatenated. (See page 50 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.6.0.1

Summary

Block scope declarations shall not be visually ambiguous. (See page 51 of MISRA-CPP-2023 [56] .)

Description

A block scope declaration is reported when:

  • it declares a function; or

  • it declares an object where the name is in parentheses

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.0.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.0.2

Summary

When an array with external linkage is declared, its size should be explicitly specified. (See page 52 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.0.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.0.3

Summary

The only declarations in the global namespace should be main, namespace declarations and extern "C" declarations. (See page 52 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.0.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option naming
naming
-config=MP2.6.0.3,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MP2.6.0.3,naming=mp1

Rule MP2.6.0.4

Summary

The identifier main shall not be used for a function other than the global function main. (See page 53 of MISRA-CPP-2023 [56] .)

Description

Additional functions can be identified as entry points to the program using the -extra_references global configuration. For example, the following configuration declares that any function with unqualified name my_main may be used as an entry point:

-extra_references+={"", "name(my_main)"}

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.0.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.2.1

Summary

The one-definition rule shall not be violated. (See page 54 of MISRA-CPP-2023 [56] .)

Description

See [basic.def.odr] in C++ standard 2017 [42]

It is reported if any variable, function, class type, enumeration type, or template thereof has:

  • no definition; or

  • multiple non-inline definitions in different translation units; or

  • multiple inline definitions in different translation units that are not the same; or

  • different initializer values.

Note that by inline, we include here all the entities specified in paragraph 6 of [basic.def.odr] in C++ standard 2017 [42].

Imprecision

when the analyzer is unsure is a function template definition is an overload, the definition is reported as a caution.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.2.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.2.2

Summary

All declarations of a variable or function shall have the same type. (See page 56 of MISRA-CPP-2023 [56] .)

Description

More specifically:

  • if a variable is declared more than once, the types must be compatible;

  • if a function has more than one prototype declaration or definition, the corresponding parameter types or return types must be compatible.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.2.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.2.3

Summary

The source code used to implement an entity shall appear only once. (See page 57 of MISRA-CPP-2023 [56] .)

Description

It is reported if all the definitions of an entity are the same but in different locations.

Imprecision

when the analyzer is unsure is a function template definition is an overload, the definition is reported as a caution.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.2.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.2.4

Summary

A header file shall not contain definitions of functions or objects that are non-inline and have external linkage. (See page 59 of MISRA-CPP-2023 [56] .)

Description

A definition within a header file is reported if the entity has external linkage, is non-inline and is:

  • a namespace-scope variable;

  • a namespace-scope function;

  • a member function; or

  • a non-const, static data member.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.2.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.4.1

Summary

A variable declared in an inner scope shall not hide a variable declared in an outer scope. (See page 60 of MISRA-CPP-2023 [56] .)

Description

Declarations of variables, fields, function parameters and enumerators of unscoped enumeration type are considered by this rule as variable declarations

The relation outer and inner scope, defined in MISRA CPP:2023 [56] , is summarized as:

  • global scope is the outermost scope;

  • compound statements and classes introduce a new inner scope;

  • function definition parameters have the same scope as the function body;

  • a derived class introduces an inner scope relative to the scope of the base class;

  • selection and iteration statements introduce an inner scope;

  • a using declaration updates the scopes of the named entities with the current scope.

Exceptions

A class constructor parameter may have the same name as a field of the same class, provided that the only use made of that parameter is to initialize the field.

Configuration

See generic service options.

Option similar_map
similar_map
-config=MP2.6.4.1,similar_map={MATCH_ID, MAPPING},...

Specify mappings of identifiers to their canonical form.

The configuration’s content is a list of identifier mappings.

MATCH_ID:

the identifier for the selected entities.

MAPPING:

. Accepted forms are:

  • std(REGEX): matches a service

  • min(NUMBER,CASE): the identifier prefix of length NUMBER, (after convertion to upper-case, if CASE is case_insensitive), is the canonical form

  • REPLACER[||REPLACER]*): a list of alternative REPLACERs (see the -replacer global configuration) defining the replacements that map the identifier to its canonical forms

CASE

accepted forms are:

  • case_sensitive: the identifier is case-sensitive

  • case_insensitive: the identifier is case-insensitive and the canonical form has all letters converted to upper-case

Default:

-config=MP2.6.4.1,similar_map={introduces_any_var_id_entity, $0}

Option ignored_decls
ignored_decls
-config=MP2.6.4.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=MP2.6.4.1,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.6.5.1

Summary

A function or object with external linkage should be introduced in a header file. (See page 66 of MISRA-CPP-2023 [56] .)

Description

More specifically:

  • any variable or function with external linkage and not declared in an anonymous namespace must be declared in a header file;

  • the first declaration of a function or variable in a unit must be in a header file.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.5.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.5.2

Summary

Internal linkage should be specified appropriately. (See page 67 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.5.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.7.1

Summary

Local variables shall not have static storage duration. (See page 68 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.7.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.7.2

Summary

Global variables shall not be used. (See page 69 of MISRA-CPP-2023 [56] .)

Description

Any variable with namespace scope or any static data member is reported unless:

  • it is declared constexpr, or

  • it is const and has a constant initializer.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.7.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.8.1

Summary

An object shall not be accessed outside of its lifetime. (See page 70 of MISRA-CPP-2023 [56] .)

Imprecision

False negatives are present due to the undecidability of the guideline.

Configuration

See generic service options.

Rule MP2.6.8.2

Summary

A function must not return a reference or a pointer to a local variable with automatic storage duration. (See page 71 of MISRA-CPP-2023 [56] .)

Description

Reports if a function returns a reference or a pointer to:

  • an object with automatic storage duration

  • to a parameter passed by value

  • a pointer to a variable captured by a lambda with automatic storage duration

Configuration

See generic service options.

Rule MP2.6.8.3

Summary

An assignment operator shall not assign the address of an object with automatic storage duration to an object with a greater lifetime. (See page 73 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.6.8.4

Summary

Member functions returning references to their object should be ref-qualified appropriately. (See page 74 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.8.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.9.1

Summary

The same type aliases shall be used in all declarations of the same entity. (See page 76 of MISRA-CPP-2023 [56] .)

Description

Note that this rule ignores qualifiers.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.6.9.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.6.9.2

Summary

The names of the standard signed integer types and standard unsigned integer types should not be used. (See page 77 of MISRA-CPP-2023 [56] .)

Description

Notes:

  • The ISO (POSIX) typedefs are taken as the default schema.

  • The naming service configuration can be used to change the schema.

Configuration

See generic service options.

Option naming
naming
-config=MP2.6.9.2,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=MP2.6.9.2,naming=mp1

Option declarations
declarations
-config=MP2.6.9.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP2.6.9.2,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP2.7.0.1

Summary

There shall be no conversion from type bool. (See page 80 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.7.0.1,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option statements
statements
-config=MP2.7.0.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.7.0.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.7.0.2

Summary

There shall be no conversion to type bool. (See page 81 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.7.0.2,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option statements
statements
-config=MP2.7.0.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.7.0.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.7.0.3

Summary

The numerical value of a character shall not be used. (See page 83 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.7.0.3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.7.0.4

Summary

The operands of bitwise operators and shift operators shall be appropriate. (See page 84 of MISRA-CPP-2023 [56] .)

Description

The following operands must be unsigned:

  • both operands of the binary bitwise operators;

  • the left operand of the shift operators;

  • the operand of the bit complement operator.

In addition, the right operand of the shift operators, must be:

  • a non-constant expression with an unsigned type; or

  • a constant expression with a value between 0 and sizeof( T ) * CHAR_BIT - 1 (inclusive), where T is the type of the left operand (before integral promotion).

Note that for shift operators having arguments of templatic type, a single report is produced for each non-compliant type instantiation.

Imprecision

The exception for shift operators with constant operands is not supported (see Rule 7.0.4 on page 85 of MISRA-CPP:2023 [56] )

Configuration

See generic service options.

Option statements
statements
-config=MP2.7.0.4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.7.0.4,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.7.0.5

Summary

Integral promotion and the usual arithmetic conversions shall not change the signedness or the type category of an operand. (See page 86 of MISRA-CPP-2023 [56] .)

Description

Any syntactic expression that occurs as an operand to a comparative, arithmetic, bitwise, shift or compound assign operator with a type that is:

  • integral and implicitly converted to a type that has a different sign,

  • integral and implicitly converted to a floating type or

  • floating and implicitly converted to an integral type

is reported.

Notes:

  • The check is between the type of the syntactic expression and the type of the operand; intermediate conversions are ignored.

  • Compile-time constants are not reported unless:

    • the conversion is from an unsigned type or

    • the type is signed and the expression has a negative value.

    • the conversion is from a floating type to an integral type,

  • In addition, any expression in a preprocessor directive that occurs as an operand to a comparative, arithmetic, bitwise or shift operator with that has a negative value and will be converted to an unsigned type is reported.

Configuration

See generic service options.

Option casts
casts
-config=MP2.7.0.5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option statements
statements
-config=MP2.7.0.5,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.7.0.5,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.7.0.6

Summary

Assignment between numeric types shall be appropriate. (See page 87 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.7.0.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option statements
statements
-config=MP2.7.0.6,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MP2.7.11.1

Summary

nullptr shall be the only form of the null-pointer-constant. (See page 91 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option macros
macros
-config=MP2.7.11.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.7.11.2

Summary

An array passed as a function argument shall not decay to a pointer. (See page 92 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.7.11.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.7.11.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.7.11.3

Summary

A conversion from function type to pointer-to-function type shall only occur in appropriate contexts. (See page 93 of MISRA-CPP-2023 [56] .)

Imprecision

False negatives in conversion of lambda expressions.

Configuration

See generic service options.

Option casts
casts
-config=MP2.7.11.3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.0.1

Summary

Parentheses should be used to make the meaning of an expression appropriately explicit. (See page 95 of MISRA-CPP-2023 [56] .)

Description

Note that the following operators and their precedences (as given in MISRA CPP:2023 [56] ) are assumed:

13 Multiplicative  * / %
12 Additive        + -
11 Bitwise Shift   << >>
10 Relational      < <= > >=
9  Equality        == !=
8  Bitwise AND     &
7  Bitwise XOR     ^
6  Bitwise OR      |
5  Logical AND     &&
4  Logical OR      ||
3  Conditional     ?:
2  Assignment      = etc
1  Throw           throw
0  Comma           ,

The trusted_pairs service configuration can be used to specify report tags for selected pairs of operators where the first matches the expression’s main operator and the second matches an operator of one of its operands. For example:

-doc="Programmers are aware of the precedence between relational and arithmetic operators, no developer confusion possible."
-config=MP2.8.0.1,trusted_pairs={safe, relational:arithmetic}

will deviate reports for expressions such as a > b+c and b+c < a.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=MP2.8.0.1,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule MP2.8.1.1

Summary

A non-transient lambda shall not implicitly capture this. (See page 97 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.1.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MP2.8.1.2

Summary

Variables should be captured explicitly in a non-transient lambda. (See page 97 of MISRA-CPP-2023 [56] .)

Imprecision

Cautions are reported for non-explicit captures when it cannot be determined whether a lambda expression is definitely transient or not

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.1.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MP2.8.2.1

Summary

A virtual base class shall only be cast to a derived class by means of dynamic_cast. (See page 99 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.1,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.2

Summary

C-style casts and functional notation casts shall not be used. (See page 100 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.2,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.3

Summary

A cast shall not remove any const or volatile qualification from the type accessed via a pointer or by reference. (See page 101 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.4

Summary

Casts shall not be performed between a pointer to function and any other type. (See page 102 of MISRA-CPP-2023 [56] .)

Description

Note that reports for non-compliant conversions can be tagged using the casts service configuration. For example, with the configuration lines:

-doc="Implicit conversions."
-config=MP2.8.2.4,casts={implicit_conversion, "class(implicit)"}
-doc="Explicit conversions."
-config=MP2.8.2.4,casts={cast, "!class(implicit)"}

reports concerning the implicit conversions will have the tag implicit_conversion while reports concerning explicit casts will have the tag cast.

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.5

Summary

reinterpret_cast shall not be used. (See page 103 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.6

Summary

An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type. (See page 104 of MISRA-CPP-2023 [56] .)

Description

The following casts are reported:

  • the cast is from an integer or enumerated type to a pointer type;

  • the cast is from a pointer to void to a pointer type that is not a pointer to void, or a pointer to function.

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.6,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.7

Summary

A cast should not convert a pointer type to an integral type. (See page 105 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.7,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.8

Summary

An object pointer type shall not be cast to an integral type other than std::uintptr_t or std::intptr_t. (See page 106 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option casts
casts
-config=MP2.8.2.8,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule MP2.8.2.9

Summary

The operand to typeid shall not be an expression of polymorphic class type. (See page 107 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.2.9,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.8.2.9,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.8.2.10

Summary

Functions shall not call themselves, either directly or indirectly. (See page 108 of MISRA-CPP-2023 [56] .)

Description

For any function that is non-compliant, the report will show all calls in the chain that lead to it calling itself.

Imprecision

The exception in the source is not supported. Cautions are reported when the recursion relies on indirect function calls to form the chain.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.8.2.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_edges
ignored_edges
-config=MP2.8.2.10,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule MP2.8.2.11

Summary

An argument passed via ellipsis shall have an appropriate type. (See page 109 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.2.11,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.8.2.11,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.8.3.1

Summary

The built-in unary - operator should not be applied to an expression of unsigned type. (See page 110 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.3.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.8.3.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.8.3.2

Summary

The built-in unary + operator should not be used. (See page 111 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.3.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.8.3.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.8.7.1

Summary

Pointer arithmetic shall not form an invalid pointer. (See page 112 of MISRA-CPP-2023 [56] .)

Imprecision

Cautions are reported for every suspect case found.

False negatives are present when the checker precision is insufficient.

Configuration

See generic service options.

Rule MP2.8.7.2

Summary

Subtraction between pointers shall only be applied to pointers that address elements of the same array. (See page 114 of MISRA-CPP-2023 [56] .)

Description

Note that, for this rule, there is no requirement that the pointers have array types.

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported. For example, with the configuration line:

-decl_properties+={"^(data_end|data_start)$", {"alloc_id(alloc_data)"}}
extern char data_start[];
extern const char data_end[];

int main() {
char * p = data_end - data_start;
}

the subtraction data_end-data_start is not reported.

Imprecision

Cautions are reported when the checker is uncertain whether the pointer points to an array.

Configuration

See generic service options.

Rule MP2.8.9.1

Summary

The built-in relational operators >, >=, < and <= shall not be applied to objects of pointer type, except where they point to elements of the same array. (See page 115 of MISRA-CPP-2023 [56] .)

Description

Note that, for this rule, there is no requirement that the pointers have array types.

The -decl_properties global configuration can be used to specify an allocation identifier for the operands. Operators whose operands are variables with the same allocation identifier are not reported. For example, with the configuration line:

-decl_properties+={"^(data_end|data_start)$", {"alloc_id(alloc_data)"}}
extern char data_start[];
extern const char data_end[];

int main() {
char * p = data_end > data_start;
}

the comparison data_end > data_start is not reported.

Imprecision

Cautions are reported when the checker is uncertain whether the pointer points to an array.

Configuration

See generic service options.

Rule MP2.8.14.1

Summary

The right-hand operand of a logical && or || operator should not contain persistent side effects. (See page 116 of MISRA-CPP-2023 [56] .)

Description

It is assumed that a call to a function has side effects unless the call is declared to have impact property const, pure or noeffect.

The -call_properties global configuration can be used to specify the call property. For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when the right operand is a call to a function not declared to be noeffect.

Configuration

See generic service options.

Option effects
effects
-config=MP2.8.14.1,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule MP2.8.18.1

Summary

An object or subobject must not be copied to an overlapping object. (See page 117 of MISRA-CPP-2023 [56] .)

Description

It is reported if:

  • the library function memcpy for copying objects is used to copy (possibly) overlapping objects;

  • a member of a union is copied to another member (or subexpression of another member) of the same union that points to the same allocation area and has incompatible type; or

  • a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union.

An exception to the last item is when a sub-expression of a member of a union is assigned to a sub-expression of another member of the same union, both members are arrays and the sub-expressions are array elements with the same type and they are at the same constant offset.

Imprecision

Cautions are reported when the analyzer is uncertain whether the objects overlap.

False positives are reported because the rule needs a deeper (much more expensive) semantic analysis.

False negatives are present because the rule needs a deeper (much more expensive) semantic analysis.

Configuration

See generic service options.

Rule MP2.8.18.2

Summary

The result of an assignment operator should not be used. (See page 118 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.18.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.8.18.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.8.19.1

Summary

The comma operator should not be used. (See page 119 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.8.19.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.8.19.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.8.20.1

Summary

An unsigned arithmetic operation with constant operands should not wrap. (See page 119 of MISRA-CPP-2023 [56] .)

Description

Note that this applies to preprocessor conditional expressions as well as source code expressions.

Configuration

See generic service options.

Rule MP2.9.2.1

Summary

An explicit type conversion shall not be an expression statement. (See page 121 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.9.2.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.9.2.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.9.3.1

Summary

The body of an iteration-statement or a selection-statement shall be a compound-statement. (See page 122 of MISRA-CPP-2023 [56] .)

Description

More specifically, the rule reports:

  • any switch, do, for, or while statement that does not have its body enclosed in braces;

  • any if statement that does not have the condition part immediately followed by a compound statement;

  • any else keyword that is not followed by another if statement or by a compound statement.

Configuration

See generic service options.

Rule MP2.9.4.1

Summary

All if ... else if constructs shall be terminated with an else statement. (See page 123 of MISRA-CPP-2023 [56] .)

Description

The service will report any if statement if the final else if has no else clause.

Configuration

See generic service options.

Option else_empty
else_empty
-config=MP2.9.4.1,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=MP2.9.4.1,else_empty={missing, "none()"}

Option ignored_comments
ignored_comments
-config=MP2.9.4.1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP2.9.4.2

Summary

The structure of a switch statement shall be appropriate. (See page 124 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option terminals
terminals
-config=MP2.9.4.2,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=MP2.9.4.2,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=MP2.9.4.2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule MP2.9.5.1

Summary

Legacy for statements should be simple. (See page 127 of MISRA-CPP-2023 [56] .)

Imprecision

Cautions are reported when the analyzer cannot determine if all the conditions are fully satisfied.

Cautions are reported when:

  • the analyzer cannot determine if a control variable that is not a loop counter and does not have Boolean type may be modified in the body;

  • the non-const address of a control variable is taken.

Configuration

See generic service options.

Option for_structure
for_structure
-config=MP2.9.5.1,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=MP2.9.5.1,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=MP2.9.5.1,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule MP2.9.5.2

Summary

A for-range-initializer shall contain at most one function call. (See page 129 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.9.5.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MP2.9.6.1

Summary

The goto statement should not be used. (See page 130 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.9.6.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.9.6.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.9.6.2

Summary

A goto statement shall reference a label in a surrounding block. (See page 131 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.9.6.3

Summary

The goto statement shall jump to a label declared later in the function body. (See page 132 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.9.6.4

Summary

A function declared with the [[noreturn]] attribute shall not return. (See page 133 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.9.6.4,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.9.6.4,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=MP2.9.6.4,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MP2.9.6.5

Summary

A function with non-void return type shall return a value on all paths. (See page 134 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.9.6.5,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.9.6.5,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=MP2.9.6.5,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule MP2.10.0.1

Summary

A declaration should not declare more than one variable or member variable. (See page 135 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.10.1.1

Summary

The target type of a pointer or lvalue reference parameter should be const-qualified appropriately. (See page 135 of MISRA-CPP-2023 [56] .)

Description

It is always considered appropriate to const-qualify the target type of a pointer or lvalue reference parameter, unless:

  1. it is not an object type;

  2. the parameter is assigned to a pointer or reference with a non-const target type;

  3. the target object is modified;

The rule does not apply to parameters:

  1. unnamed;

  2. of virtual functions;

  3. of function templates;

  4. of functions declared within a template scope.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=MP2.10.1.1,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=MP2.10.1.1,show_declarations=all

Option single_assign
single_assign
-config=MP2.10.1.1,single_assign=BOOL

Specify if an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const.

BOOL:

boolean. Accepted values are:

  • true: an uninitialized local variable declaration with a single assignment will be considered for converting the constness to const;

  • false: an uninitialized local variable declaration with a single assignment will not be considered for converting the constness to const;

Default:

-config=MP2.10.1.1,single_assign=false

Option declarations
declarations
-config=MP2.10.1.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MP2.10.1.1,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

Default:

-config=MP2.10.1.1,ignored_decls="type(canonical(node(rvalue_reference)))||context(instance(instantiation))"

Option all_decls
all_decls
-config=MP2.10.1.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule MP2.10.1.2

Summary

The volatile qualifier shall be used appropriately. (See page 137 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.10.1.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.10.2.1

Summary

An enumeration shall be defined with an explicit underlying type. (See page 138 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.10.2.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.10.2.2

Summary

Unscoped enumerations should not be declared. (See page 139 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.10.2.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.10.2.3

Summary

The numeric value of an unscoped enumeration with no fixed underlying type shall not be used. (See page 140 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.10.2.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option statements
statements
-config=MP2.10.2.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Rule MP2.10.3.1

Summary

There should be no unnamed namespaces in header files. (See page 141 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.10.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.10.4.1

Summary

The asm declaration shall not be used. (See page 142 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.10.4.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.11.3.1

Summary

Variables of array type should not be declared. (See page 143 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.11.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.11.3.2

Summary

The declaration of an object should contain no more than two levels of pointer indirection. (See page 144 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.11.6.1

Summary

All variables should be initialized. (See page 145 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.11.6.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.11.6.2

Summary

The value of an object must not be read before it has been set. (See page 146 of MISRA-CPP-2023 [56] .)

Description

Notes:

  • Objects should be initialized when declared or be written to before use.

  • Initializing any one member of a union is not considered as (proper) initialization of the other members.

  • To specify the read and write properties for the called functions, use the -call_properties global configuration with properties pointee_read and pointee_write for the read and write properties of non-const parameters and const_pointee_read and const_pointee_write for the read and write properties of const parameters.

For example, with the configuration line:

-call_properties+={"decl(name(gettimeofday))",
{"pointee_read(1..=never)",
"pointee_write(1..=always)"}}

the first argument in a call to the function gettimeofday is not reported for not being initialized and, after the call, it is assumed that the first argument has been initialized.

Imprecision

Cautions are reported when the checker cannot determine the necessary execution order or whether all the components of a data structure have been initialized.

  • Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}
  • In the presence of backward or sideways jumps, the results are unreliable.

int p(int y) {
  int x;
  int i = 0;
loop:
  if (i < y) {
    if (i > 0) {
      return x;
    }
    x = 4;
    ++i;
    goto loop;
  }
  return 0;
}

There may be false positives when there are backward goto jumps or when the goto jumps break the control structures.

There may be false negatives when constructors do not fully initialize an object.

Configuration

See generic service options.

Option member_areas
member_areas
-config=MP2.11.6.2,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=MP2.11.6.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=MP2.11.6.2,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.11.6.3

Summary

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique. (See page 148 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.12.2.1

Summary

Bit-fields should not be declared. (See page 149 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.12.2.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.12.2.2

Summary

A bit-field shall have an appropriate type. (See page 150 of MISRA-CPP-2023 [56] .)

Description

The defined type for bit-fields must be:

  • a signed or unsigned integer, or

  • enum with a fixed underlying type of signed or unsigned integer type, provided that all of its enumeration values are representable within the width of the bit-field

  • bool

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.12.2.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP2.12.2.2,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP2.12.2.3

Summary

A named bit-field with signed integer type shall not have a length of one bit. (See page 151 of MISRA-CPP-2023 [56] .)

Description

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.12.2.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP2.12.2.3,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP2.12.3.1

Summary

The union keyword shall not be used. (See page 151 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.12.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=MP2.12.3.1,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule MP2.13.1.1

Summary

Classes should not be inherited virtually. (See page 152 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.13.1.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.13.1.2

Summary

An accessible base class shall not be both virtual and non-virtual in the same hierarchy. (See page 153 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.13.3.1

Summary

User-declared member functions shall use the virtual, override and final specifiers appropriately. (See page 153 of MISRA-CPP-2023 [56] .)

Description

The specifiers are used appropriately when a member function declaration:

  • Does not override a function in a base class, and has either no specifier or has the virtual specifier; or

  • Overrides a function in a base class, does not use the virtual specifier, and does use either the override or final specifier

  • bool

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.13.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.13.3.2

Summary

Parameters in an overriding virtual function shall not specify different default arguments. (See page 155 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.13.3.3

Summary

The parameters in all declarations or overrides of a function shall either be unnamed or have identical names. (See page 156 of MISRA-CPP-2023 [56] .)

Description

Note that it is not reported if parameters in a templatic function differ from matching positions in any instance of the function. For example, with the code:

template<typename T>
void foo (T a) {};
template void foo(int b);

there will be no violation for parameters a and b.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.13.3.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.13.3.4

Summary

A comparison of a potentially virtual pointer to member function shall only be with nullptr. (See page 157 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.14.1.1

Summary

Non-static data members should be either all private or all public. (See page 158 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.14.1.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.15.0.2

Summary

User-provided copy and move member functions of a class should have appropriate signatures. (See page 162 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.15.0.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.15.1.1

Summary

An object’s dynamic type shall not be used from within its constructor or destructor. (See page 164 of MISRA-CPP-2023 [56] .)

Description

In a class with a virtual method or with a virtual method in a base class, the service reports every direct use of this in each of the following contexts:

  • the typeid operator;

  • a dynamic_cast;

  • a call to a virtual function of the same class.

The following are reported as cautions:

  • a call to a non-virtual non-static method of the class;

  • a call to a function if this is passed as argument;

  • a call to a static method of the class if this is passed as argument;

  • a call to any method of a different class where this is passed as argument.

Imprecision

calls to methods and functions (as specified in the description) are reported as cautions since they may be due to an undefined use of the object’s dynamic type

Configuration

See generic service options.

Rule MP2.15.1.2

Summary

All constructors of a class should explicitly initialize all of its virtual base classes and immediate base classes. (See page 165 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.15.1.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.15.1.3

Summary

Conversion operators and constructors that are callable with a single argument shall be explicit. (See page 167 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.15.1.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.15.1.4

Summary

All direct, non-static data members of a class should be initialized before the class object is accessible. (See page 168 of MISRA-CPP-2023 [56] .)

Description

Any direct, non-static, member of a class that is not initialized in the member initializer list is shown

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=MP2.15.1.4,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MP2.16.5.1

Summary

The logical AND and logical OR operators shall not be overloaded. (See page 174 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.16.5.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.16.5.2

Summary

The address-of operator shall not be overloaded. (See page 175 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.16.5.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.16.6.1

Summary

Symmetrical operators should only be implemented as non-member functions. (See page 176 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.16.6.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.17.8.1

Summary

Function templates shall not be explicitly specialized. (See page 177 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.18.1.1

Summary

An exception object shall not have pointer type. (See page 179 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.18.1.2

Summary

An empty throw shall only occur within the compound-statement of a catch handler. (See page 180 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.18.1.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.18.1.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.18.3.1

Summary

There should be at least one exception handler to catch all otherwise unhandled exceptions. (See page 181 of MISRA-CPP-2023 [56] .)

Description

The body of main or any other top-level function must be either:

  • a function-try-block with a catch-all handler that does not itself throw an exception or call that does not have the impact property nothrow; or

  • a compound statement containing one or more try-catch statements that have catch-all handlers and an optional return statement whose argument is a constant initializer or call that has the impact property nothrow.

Notes:

  • A call to a function has the impact property nothrow if the function is declared with a noexcept-specifier to not throw exceptions or it is specified as nothrow using the -call_properties global configuration.

  • A project can specify the entry points (in addition to the function main) using the -extra_references global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.18.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.18.3.2

Summary

An exception of class type shall be caught by const reference or reference. (See page 182 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.18.3.3

Summary

Handlers for a function-try-block of a constructor or destructor shall not refer to non-static members from their class or its bases. (See page 183 of MISRA-CPP-2023 [56] .)

Implementation

There will be a report if a this expression has a chain of ancestors in the following order:

  • any sequence of expressions or statements,

  • a catch statement,

  • any sequence of declarations or statements except a function definition,

  • a try statement,

  • a constructor or a destructor definition.

Configuration

See generic service options.

Option statements
statements
-config=MP2.18.3.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.18.3.3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.18.4.1

Summary

Exception-unfriendly functions shall be noexcept. (See page 184 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option calls
calls
-config=MP2.18.4.1,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MP2.18.4.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option declarations
declarations
-config=MP2.18.4.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.18.5.1

Summary

A noexcept function should not attempt to propagate an exception to the calling function. (See page 186 of MISRA-CPP-2023 [56] .)

Description

The service reports each function labelled with the nothrow impact property:

  • if it has an uncaught throw;

  • if it calls a function that does not have the nothrow property and does not have a catch-all for that call;

  • if a type that does not have the nothrow property is converted to a function type with the nothrow property.

Notes:

  • A function has the impact property nothrow if it is declared with a noexcept-specifier to not throw exceptions or it is specified as nothrow using -call_properties global configuration;

  • A destructor could be called implicitly from stack deallocation, if it occurs after the completing the initialization of an exception object but before activation of a handler for the exception and cause a call to terminate(). For this reason, the service reports all the destructors with possible exceptions.

  • the impacts service configuration can be used to tag reports about functions where the declared property is less strict than the body’s property

Using the default configuration of the impacts service configuration, functions with the nothrow property, but not declared as such are not reported. This can be changed by setting the properties service configuration.

Imprecision

The following cases are reported as cautions if not handled with a catch-all block:

  • implicit and explicit calls to functions that do not have the property nothrow;

  • implicit calls to destructors due to the stack deallocation;

  • typeid expressions on polymorphic arguments;

  • dynamic_cast expressions.

  • if the analyzer is uncertain whether a type that does not have the nothrow property could be converted to a function type with the nothrow property

Configuration

See generic service options.

Option impacts
impacts
-config=MP2.18.5.1,impacts={TAGS, PROP_MATCHER},...

Associates a set of tags to a matching pair of impact properties (the function’s declared impact and the inferred body’s impact).

The configuration’s content is list of pairs of a set of report taggers with a impacts matcher.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PROP_MATCHER:

an expression defining the matching impacts. Accepted forms are:

  • [+]AND_MATCHER: the property pair matches AND_MATCHER

  • -AND_MATCHER: the property pair does not match AND_MATCHER

  • [+]AND_MATCHER||PROP_MATCHER: either the property pair matches AND_MATCHER or it matches PROP_MATCHER

  • -AND_MATCHER||PROP_MATCHER: the property pair does not match AND_MATCHER but does match PROP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the property pair matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the property pair matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PROP_MATCHER): the property pair matches PROP_MATCHER

  • !BASIC_MATCHER: the property pair does not match BASIC_MATCHER

  • any(): any property pair matches

  • none(): no property pair matches

  • decl([REL]IMPACTS): the declared property must be in a strictness relation REL with IMPACTS; if no relation is specified, the declared property must be the same as IMPACTS

  • body([REL]IMPACTS): the body’s property must be in a strictness relation REL with IMPACTS; if no relation is specified, the body’s property must be the same as IMPACTS

IMPACTS

accepted forms are:

  • IMPACT[||IMPACT]*): one of the IMPACTs

IMPACT

accepted forms are:

  • const: call is const. That is, it is assumed that the called function is const

  • fp_const: the floating-point environment is unchanged and the call is const

  • pure: call is pure. That is, it is assumed that the called function is pure

  • noeffect: a call to a function with no external side effect. That is, it is assumed that: there are no indirect calls; any throw is caught within the function; there are no calls to new, delete, a non-trivial constructor or a destructor; it does not write to a variable that is volatile or has static storage; and it does not read from a volatile variable that triggers a side effects

  • nothrow: a call to a function for which it is assumed that any thrown exceptions are caught within the function

  • any: the call can have any impact

REL

accepted forms are:

  • =: the same

  • >: less strict

  • >=: the same or less strict

  • <: stricter

  • <=: the same or stricter

Default:

-config=MP2.18.5.1,impacts={hide, "any()"}

Option declarations
declarations
-config=MP2.18.5.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.18.5.2

Summary

Program-terminating functions should not be used. (See page 188 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MP2.18.5.2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MP2.18.5.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.19.0.1

Summary

A line whose first token is # shall be a valid preprocessing directive. (See page 189 of MISRA-CPP-2023 [56] .)

Description

Reports a preprocessing directive if:

  • it is not one of the preprocessing tokens specified in Section 19 of the C++17 standard [42];

  • it is a conditional directives that does not follow the pattern specified in Section 19 of the C++17 standard [42];

  • it is an #else or #endif directive that is followed by a character (ignoring any white space or comment tokens and before any newline character).

Notes:

  • any parsing error in the preprocessing code that is not excluded by conditional compilation will be reported by the service B.PARSER;

  • a preprocessing directive always begins with a # and the last token in the sequence is the first newline character that follows the first token in the sequence;

  • for this service, the report category is the directive name.

This service depends upon the configuration of the following ancillary services: STD.prepdirc

Configuration

See generic service options.

Option behaviors
behaviors
-config=MP2.19.0.1,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Rule MP2.19.0.2

Summary

Function-like macros shall not be defined. (See page 190 of MISRA-CPP-2023 [56] .)

Exceptions

A function-like macro is non-compliant unless the macro body or the bodies of any macros that are called by it contain the special tokens:

  • __LINE__,

  • __FILE__,

  • __func__,

  • # or

  • ##.

Configuration

See generic service options.

Option macros
macros
-config=MP2.19.0.2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.19.0.3

Summary

#include directives should only be preceded by preprocessor directives or comments. (See page 191 of MISRA-CPP-2023 [56] .)

Exceptions

The exception service configuration allows for some exceptions.

Configuration

See generic service options.

Option headers
headers
-config=MP2.19.0.3,headers={TAGS, HEADER_MATCHER},...

Specifies report tags for the #include directives.

The configuration’s content is a list of clauses specifying report tags for matching #include names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

HEADER_MATCHER:

the #include argument matcher including quotes or chevrons. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option exception
exception
-config=MP2.19.0.3,exception=EXCEPT,...

Specify allowed exceptions to this rule.

{EXCEPT,…}:

allowed exception to this rule. Accepted members are:

  • extern_C: constructs of the form extern "C" {...} are not considered to be code (for ‘C++’ rules);

  • extern_C_only: constructs of the form extern "C" are not considered to be code (for ‘C++’ rules); the following {…} may only contain preprocessor directives;

  • namespace_alias: constructs of the form namespace A = B are not considered to be code;

  • if_directive: directive subsections that are bounded by the #if, #else, #elif and #endif directives are considered as separate code chunks;

Default:

-config=MP2.19.0.3,exception=extern_C_only

Rule MP2.19.0.4

Summary

#undef should only be used for macros defined previously in the same file. (See page 192 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option macros
macros
-config=MP2.19.0.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.19.1.1

Summary

The defined preprocessor operator shall be used appropriately. (See page 192 of MISRA-CPP-2023 [56] .)

Description

The defined preprocessor operator must use one of the two forms permitted by the standard (see Section 19.1 of the C++17 standard [42].

Additionally the defined token must not be generated by macro expansion during the expansion of a #if or #elif directive.

Configuration

See generic service options.

Rule MP2.19.1.2

Summary

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related. (See page 193 of MISRA-CPP-2023 [56] .)

Description

Note that these constructs will be reported by the ECLAIR rule B.PARSER.

Configuration

See generic service options.

Rule MP2.19.1.3

Summary

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be defined prior to evaluation. (See page 194 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.19.2.1

Summary

Precautions shall be taken in order to prevent the contents of a header file being included more than once. (See page 194 of MISRA-CPP-2023 [56] .)

Description

Note that this applies to any included file regardless of the file name extension.

Such a file must use one of the mechanisms: ifndef, ifdef and pragma where these are defined by the forms:

  • ifndef

#ifndef Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
#if !defined Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
  • ifdef

#ifdef Guard_Id
#else
#define Guard_Id ...
...
#endif
#if defined Guard_Id
#else
#define Guard_Id ...
...
#endif
  • pragma

#pragma first

It is also shown if the guard’s macro name is used elsewhere in any #define or #undef in the project.

There are no checks on the form or syntax of the macro name.

Configuration

See generic service options.

Option guard
guard
-config=MP2.19.2.1,guard={FILE, {CHECK,...}},...

Specify the allowed mechanisms to prevent the contents of a header file being included twice using advanced features.

The configuration’s content is an ordered list of file selectors with conditions; the conditions in the first clause whose file selector matches the file are checked.

FILE:

a -file_tag identifier or a matcher expression used to select the files.

CHECK

Accepted forms are:

  • mechanism(MECHANISM[||MECHANISM]*): the guard’s mechanism

  • guard(GUARD): the file name replacer REPLACER (see the -replacer global configuration). The input provided to the replacer is the canonical pathname of the guarded file; the macro name must match exactly, or must match the regular expression defined by FMT

  • comment(COMMENT_MATCHER): it will be reported if there is no matching comment following the #endif

  • reuse(REUSE_TAG): tag indicating if what reuse of the macro name should be reported

  • regex(): the replaced name is a regular expression that must match the macro guard name

REUSE_TAG

accepted forms are:

  • all_code: it is reported if the same guard identifier is reused for an identifier anywhere in the project code

  • all_defined: it is reported if the same guard identifier is redefined or undefined anywhere in the project

  • all_guards_in_unit: it is reported if the same guard identifier is used for more than one header file in the translation unit

  • all_guards_in_project: it is reported if the same guard identifier is used for more than one header file in the project

MECHANISM

accepted forms are:

  • any: any mechanism

  • ifndef: the guard mechanism using #ifndef Guard_Id or if !defined Guard_Id

  • ifdef: the mechanism using #if defined Guard_Id

  • pragma: the mechanism #pragma once

Default:

-config=MP2.19.2.1,guard={^.*$,
    {"mechanism(any)",
      "reuse(all_defined)"}}

Option directives
directives
-config=MP2.19.2.1,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule MP2.19.2.2

Summary

The #include directive shall be followed by either a <filename> or "filename" sequence. (See page 195 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MP2.19.2.2,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MP2.19.2.2,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MP2.19.2.3

Summary

The ' or " or \ characters and the /* or // character sequences shall not occur in a header file name. (See page 196 of MISRA-CPP-2023 [56] .)

Description

To avoid the reporting of \ in file path names, the path_uses_backslash service configuration should be used.

The reports can be tagged using the include_name_exception.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=MP2.19.2.3,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=MP2.19.2.3,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule MP2.19.3.1

Summary

The # and ## preprocessor operators should not be used. (See page 196 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option macros
macros
-config=MP2.19.3.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.19.3.2

Summary

A macro parameter immediately following a # operator shall not be immediately followed by a ## operator. (See page 197 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option macros
macros
-config=MP2.19.3.2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.19.3.3

Summary

The argument to a mixed-use macro parameter shall not be subject to further expansion. (See page 197 of MISRA-CPP-2023 [56] .)

Description

A macro is reported if:

  • a parameter occurs in the body both:

    • as an operand to a # or ## operand, and

    • not as an operand to a # or ## operand, and

  • in an invocation of the macro, an argument matching this parameter includes an expanded macro.

Configuration

See generic service options.

Option macros
macros
-config=MP2.19.3.3,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.19.3.4

Summary

Parentheses shall be used to ensure macro arguments are expanded appropriately. (See page 198 of MISRA-CPP-2023 [56] .)

Description

Any macro invocation argument that expands to a complete expression that is not parenthesized or immediately enclosed in parentheses is reported.

Any macro invocation argument for which the initial and end parts of its expansion begin and end sub-expressions of a single larger expression is reported.

Notes:

  • The arg_expansion service configuration can be used to tag reports for macro invocation arguments that expand to AST nodes;

  • The expansion_context service configuration can be used to tag the reports for macro invocation arguments that expand to nodes with matching contexts.

  • the macros service configuration can be used to tag reports for the selected macros.

For example, the configure lines:

-doc="Macro invocation arguments that always expands to AST nodes are safe."
-config=MP2.19.3.4,arg_expansion={safe, safe}
-doc="Expansions in the context of cast to void are safe."
-config=MP2.19.3.4,expansion_context={safe, "context(role(to_void))"}

hide any report for a macro invocation argument that always expands to an AST node or for which the macro invocation is in the context of a cast to void.

Configuration

See generic service options.

Option arg_expansion
arg_expansion
-config=MP2.19.3.4,arg_expansion={TAGS, OPTION},...

Specify the report tag for the associated macro expansion option.

The configuration’s content is list of report tags and their associated macro expansion option.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

OPTION:

the expansion option. Accepted values are:

  • safe: a macro invocation argument is safe if it always expands to AST nodes;


Option expansion_context
expansion_context
-config=MP2.19.3.4,expansion_context={TAGS, MATCHER},...

Specify the report tag for associated expansion context matcher.

The configuration’s content is list of report tags and their associated expansion matcher option.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

expansion context matcher. Accepted forms are:

  • [+]AND_MATCHER: the expansion matches AND_MATCHER

  • -AND_MATCHER: the expansion does not match AND_MATCHER

  • [+]AND_MATCHER||EXP_MATCHER: either the expansion matches AND_MATCHER or it matches EXP_MATCHER

  • -AND_MATCHER||EXP_MATCHER: the expansion does not match AND_MATCHER but does match EXP_MATCHER

EXP_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER||EXP_MATCHER: either the expansion matches BASIC_MATCHER or it matches EXP_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EXP_MATCHER): the expansion matches EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • left_right(REGEX1,REGEX2): the tokens preceding and following the expansion matches, respectively, ^REGEX1$ and ^REGEX2$

  • context(STMT_MATCHER): the expansion is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • single_token(): the expansion is a single token

  • single_expr(): the expansion is a single expression

  • part_of_larger_expr(): the expansion is part of a larger expression

  • pp_expr(PP_MATCHER): the expansion is a preprocessor expression matching PP_EXP_MATCHER

PP_EXP_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the preprocessor expansion matches AND_MATCHER

  • -AND_MATCHER: the preprocessor expansion does not match AND_MATCHER

  • [+]AND_MATCHER||PP_EXP_MATCHER: either the preprocessor expansion matches AND_MATCHER or it matches PP_EXP_MATCHER

  • -AND_MATCHER||PP_EXP_MATCHER: the preprocessor expansion does not match AND_MATCHER but does match PP_EXP_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the expansion matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the expansion matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PP_EXP_MATCHER): the expansion matches PP_EXP_MATCHER

  • !BASIC_MATCHER: the expansion does not match BASIC_MATCHER

  • any(): any expansion matches

  • none(): no expansion matches

  • node(PP_ASTF[||PP_ASTF]*): the expansion’s representation matches one of the preprocessor AST functors

  • operator(PP_OPERATOR[||PP_OPERATOR]*): the expansion’s representation has a main operator that matches one of the preprocessor AST operators

PP_ASTF

accepted forms are:

  • binop: the expansion is a binary operator

  • unnop: the expansion is a unary operator (this includes the defined operator)

  • condop: the expansion is a conditional operator

  • pparen: the expansion is a parenthesized expression

  • pconst: the expansion is a constant value

PP_OPERATOR

accepted forms are:

  • comma: , comma operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • eq: == equality operator

  • ne: != inequality operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • add: + addition operator

  • sub: - subtraction operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • defined: defined operator


Option macros
macros
-config=MP2.19.3.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.19.3.5

Summary

Tokens that look like a preprocessing directive shall not occur within a macro argument. (See page 200 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option macros
macros
-config=MP2.19.3.5,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.19.6.1

Summary

The #pragma directive and the _Pragma operator should not be used. (See page 201 of MISRA-CPP-2023 [56] .)

Description

Unexpanded macros are not reported. For example, consider the code:

#pragma once
#define P( x ) _Pragma( #x )
P(once)

without line 3, there would be no report.

Configuration

See generic service options.

Rule MP2.21.2.1

Summary

The library functions atof, atoi, atol and atoll from <cstdlib>shall not be used. (See page 202 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.21.2.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.21.2.2

Summary

The string handling functions from <cstring>, <cstdlib>, <cwchar> and <cinttypes> shall not be used. (See page 202 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.21.2.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.21.2.2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.21.2.3

Summary

The library function system from <cstdlib> shall not be used. (See page 204 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option macros
macros
-config=MP2.21.2.3,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=MP2.21.2.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.21.2.4

Summary

The macro offsetof shall not be used. (See page 204 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.21.2.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.21.2.4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.21.6.1

Summary

Dynamic memory should not be used. (See page 207 of MISRA-CPP-2023 [56] .)

Description

Any use of functions that have the malloc property are reported

By default a function has the malloc property if:

  • the function has the attribute malloc;

  • it is one of the standard library functions malloc, calloc, realloc, aligned_alloc, free, strdup, operator new and operator delete.

Additional functions can be assigned the property malloc using the -call_properties global configuration. For example, the following configuration declares that any function whose identifier has the suffix _m has the property malloc:

-call_properties+={"decl(^.*_m\\(.*$)", {malloc}}

Imprecision

False positives are possible due to implicit uses of dynamic memory and the undecidability of the rule

Reports some implicit uses of dynamic memory due to exceptions and specializations of std::allocator

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=MP2.21.6.1,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=MP2.21.6.1,extra_statements={}

Option statements
statements
-config=MP2.21.6.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.21.6.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.21.6.2

Summary

Dynamic memory shall be managed automatically. (See page 208 of MISRA-CPP-2023 [56] .)

Description

The service reports:

  • Any use of the standard library functions malloc, calloc, realloc, free, operator new and operator delete.

  • Any use of the non-placement forms of the standard library operators new and operator delete.

  • Any use of a standard library member functions allocator or deallocator in the std namespace.

  • Any use of a standard library member function release from std::unique_ptr.

Imprecision

All uses of the standard library operators new and operator delete and all uses of the member function release are reported.

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=MP2.21.6.2,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=MP2.21.6.2,extra_statements={}

Option statements
statements
-config=MP2.21.6.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.21.6.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.21.6.3

Summary

Advanced memory management shall not be used. (See page 209 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.21.6.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.21.6.3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option declarations
declarations
-config=MP2.21.6.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option calls
calls
-config=MP2.21.6.3,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MP2.21.6.4

Summary

If a project defines either a sized or unsized version of a global operator delete, then both shall be defined. (See page 210 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.21.6.5

Summary

A pointer to an incomplete class type shall not be deleted. (See page 211 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=MP2.21.6.5,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Rule MP2.21.10.1

Summary

The features of <cstdarg> shall not be used. (See page 212 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.21.10.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.21.10.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.21.10.2

Summary

The standard header file <csetjmp> shall not be used. (See page 213 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.21.10.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.21.10.2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.21.10.3

Summary

The facilities provided by the standard header file <csignal> shall not be used. (See page 213 of MISRA-CPP-2023 [56] .)

Description

Notes:

  • Calls to the function signal() with SIG_IGN as the second argument are compliant and not reported.

  • To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option statements
statements
-config=MP2.21.10.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.21.10.3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.22.3.1

Summary

The assert macro shall not be used with a constant-expression. (See page 214 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option calls
calls
-config=MP2.22.3.1,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MP2.22.3.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.22.4.1

Summary

The literal value zero shall be the only value assigned to errno. (See page 215 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option statements
statements
-config=MP2.22.4.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.22.4.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.23.11.1

Summary

The raw pointer constructors of std::shared_ptr and std::unique_ptr should not be used. (See page 216 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option calls
calls
-config=MP2.23.11.1,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MP2.23.11.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.24.5.1

Summary

The character handling functions from <cctype> and <cwctype> shall not be used. (See page 218 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.24.5.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.24.5.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.24.5.2

Summary

The C++ Standard Library functions memcpy, memmove and memcmp from <cstring> shall not be used. (See page 218 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.24.5.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.24.5.2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.25.5.1

Summary

The setlocale and std::locale::global functions shall not be called. (See page 220 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.25.5.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.25.5.2

Summary

The pointers returned by the C++ Standard Library functions localeconv, getenv, setlocale or strerror must only be used as if they have pointer to const-qualified type. (See page 221 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.25.5.3

Summary

The pointer returned by the C++ Standard Library functions asctime, ctime, gmtime, localtime, localeconv, getenv, setlocale or strerror must not be used following a subsequent call to the same function. (See page 222 of MISRA-CPP-2023 [56] .)

Description

Two functions calls are considered to be calls to similar functions if:

  • the first is a call to the localeconv function and the second a call to the setlocale function;

  • the calls are to the asctime and ctime functions;

  • the calls are to the gmtime and localtime functions.

Imprecision

Cautions are reported when the control flow or the use of the returned value has not been fully determined.

A caution may be reported when there is a call to one of the library functions and:

  • the return value is assigned to a variable and it has not been determined if a second call follows this call before the variable is checked;

  • the return value is assigned to a local variable but this may have been assigned to another variable;

  • the return value is assigned to a non-local variable or parameter;

  • the return value for a call to one of the library functions is not saved but returned to the callee.

Configuration

See generic service options.

Option calls
calls
-config=MP2.25.5.3,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule MP2.26.3.1

Summary

std::vector should not be specialized with bool. (See page 223 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option types
types
-config=MP2.26.3.1,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MP2.26.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.28.3.1

Summary

Predicates shall not have persistent side effects. (See page 224 of MISRA-CPP-2023 [56] .)

Description

Uses of predicates that could have persistent side effects are reported.

A record predicate (struct, class or lambda) is required to:

  • be const-qualified

  • have the noeffect property on all the function call operators (operator())

Function predicates are required to have the have the noeffect property.

To specify call properties, use the -call_properties global configuration.

Note that all functions and operators annotated with the pure property are implied to be noeffect.

Imprecision

False positives are possible due to the undecidability of the rule. If it cannot be proven that a predicate does not have a persistent side effect, it is assumed to have such property.

Configuration

See generic service options.

Option calls
calls
-config=MP2.28.3.1,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MP2.28.3.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option types
types
-config=MP2.28.3.1,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=MP2.28.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.28.6.1

Summary

The argument to std::move shall be a non-const lvalue. (See page 225 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Option calls
calls
-config=MP2.28.6.1,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=MP2.28.6.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.28.6.2

Summary

Forwarding references and std::forward shall be used together. (See page 226 of MISRA-CPP-2023 [56] .)

Description

  • A forwarding reference parameter must be wrapped in a call to the library function forward; and

  • the argument to to a call to the library function forward must be a forwarding reference

Imprecision

Analysis does not check accurately if the node is a forwarding reference.

Configuration

See generic service options.

Option statements
statements
-config=MP2.28.6.2,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=MP2.28.6.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule MP2.28.6.3

Summary

An object shall not be used while in a potentially moved-from state. (See page 227 of MISRA-CPP-2023 [56] .)

Configuration

See generic service options.

Rule MP2.28.6.4

Summary

The result of std::remove, std::remove_if, std::unique and empty shall be used. (See page 228 of MISRA-CPP-2023 [56] .)

Description

Notes:

  • calls to std::remove, std::remove_if, std::unique and empty whose return value is ignored are reported;

  • calls where the return value is cast to void are not individually reported as the explicit cast to void is taken to be a deviation request by the user.

  • all calls are included in a statistical summary for the program and the called function;

  • the summary provides:

    • the number of calls to the function,

    • the number of times the return value is ignored but this was expected,

    • the number of times the return value is cast to void and

    • the number of times it is ignored unexpectedly;

  • the selection of samples to be shown can be changed using the sample_reports service configuration.

  • the number of samples shown can be changed using the use_samples service configuration.

Configuration

See generic service options.

Option sample_reports
sample_reports
-config=MP2.28.6.4,sample_reports={TAG, REPORT_MATCHER},...

Specifies the sample reports that should be shown/counted.

The configuration’s content is a short-circuit sequence specifying the reports to be chosen as samples.

TAG:

a short-circuit sequence for sample reports. Accepted values are:

  • hide: discard if it matches the associated conditions;

  • hate: avoid when possible if it matches the associated conditions;

  • kill: ignore if it matches the associated conditions;

  • show: show if it matches the associated conditions;

REPORT_MATCHER:

a -report_selector identifier or a matcher expression used to select the reports.


Option use_samples
use_samples
-config=MP2.28.6.4,use_samples={TAG, MAX},...

Specify the maximum number of samples to be output.

The configuration’s content is a list of return use tags (ignored, to_void, used) with the maximum number of samples to be output; if a use tag is not specified, then all calls matching the tag will be shown as violations.

TAG:

tag indicating the return use. Accepted values are:

  • used: return value is used;

  • ignored: return value is ignored;

  • to_void: return value is cast to void;

MAX:

maximum number of samples to be shown. It must be an integer greater than or equal to -1.

Default:

-config=MP2.28.6.4,use_samples={ignored, -1}, {to_void, -1}, {used, 0}

Option calls
calls
-config=MP2.28.6.4,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option declarations
declarations
-config=MP2.28.6.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule MP2.30.0.1

Summary

The C Library input/output functions shall not be used. (See page 229 of MISRA-CPP-2023 [56] .)

Description

To specify which files are in the standard library, use the -std_files global configuration.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.30.0.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=MP2.30.0.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule MP2.30.0.2

Summary

Reads and writes on the same file stream shall be separated by a positioning operation. (See page 230 of MISRA-CPP-2023 [56] .)

Imprecision

Cautions are reported for all calls to fopen possibly with read access and write access and any object declarations with type fstream.

Configuration

See generic service options.

Option declarations
declarations
-config=MP2.30.0.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


MISRA C++:2023 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the MISRA C++:2023 coding standard [56].

For all rules, the mapping between the MISRA C++:2023 rules and the ECLAIR service identifiers is one-to-one and straightforward. e.g., MISRA C++:2023 Rule 0.1.1 maps to ECLAIR service MP2.0.1.1.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

MP1 synopsis: supported MISRA C++:2023 rules

Id

Headline

Precision

MP2.0.0.1

A function shall not contain unreachable statements

Best-effort

MP2.0.0.2

Controlling expressions should not be invariant

Best-effort

MP2.0.1.1

A value should not be unnecessarily written to a local object

Best-effort

MP2.0.1.2

The value returned by a function shall be used

Exact

MP2.0.2.1

Variables with limited visibility should be used at least once

Exact

MP2.0.2.2

A named function parameter shall be used at least once

Exact

MP2.0.2.4

Functions with limited visibility should be used at least once

Exact

MP2.0.3.1

Floating-point arithmetic should be used appropriately

Process

MP2.4.1.1

A program shall conform to ISO/IEC 14882:2017 (C++17)

Best-effort

MP2.4.1.2

Deprecated features should not be used

Exact

MP2.4.1.3

There shall be no occurrence of undefined or critical unspecified behaviour

Best-effort

MP2.4.6.1

Operations on a memory location shall be sequenced appropriately

Best-effort

MP2.5.0.1

Trigraph-like sequences should not be used

Exact

MP2.5.7.1

The character sequence /* shall not be used within a C-style comment

Exact

MP2.5.7.2

Sections of code should not be “commented out”

Heuristic

MP2.5.7.3

Line-splicing shall not be used in // comments

Exact

MP2.5.10.1

User-defined identifiers shall have an appropriate form

Exact

MP2.5.13.1

Within character literals and non raw-string literals, \ shall only be used to form a defined escape sequence or universal character name

Exact

MP2.5.13.2

Octal escape sequences, hexadecimal escape sequences and universal character names shall be terminated

Exact

MP2.5.13.3

Octal constants shall not be used

Exact

MP2.5.13.4

Unsigned integer literals shall be appropriately suffixed

Exact

MP2.5.13.5

The lowercase form of L shall not be used as the first character in a literal suffix

Exact

MP2.5.13.6

An integer-literal of type long long shall not use a single L or l in any suffix

Exact

MP2.5.13.7

String literals with different encoding prefixes shall not be concatenated

Exact

MP2.6.0.1

Block scope declarations shall not be visually ambiguous

Exact

MP2.6.0.2

When an array with external linkage is declared, its size should be explicitly specified

Exact

MP2.6.0.3

The only declarations in the global namespace should be main, namespace declarations and extern "C" declarations

Exact

MP2.6.0.4

The identifier main shall not be used for a function other than the global function main

Exact

MP2.6.2.1

The one-definition rule shall not be violated

Complete

MP2.6.2.2

All declarations of a variable or function shall have the same type

Exact

MP2.6.2.3

The source code used to implement an entity shall appear only once

Complete

MP2.6.2.4

A header file shall not contain definitions of functions or objects that are non-inline and have external linkage

Exact

MP2.6.4.1

A variable declared in an inner scope shall not hide a variable declared in an outer scope

Exact

MP2.6.5.1

A function or object with external linkage should be introduced in a header file

Exact

MP2.6.5.2

Internal linkage should be specified appropriately

Exact

MP2.6.7.1

Local variables shall not have static storage duration

Exact

MP2.6.7.2

Global variables shall not be used

Exact

MP2.6.8.1

An object shall not be accessed outside of its lifetime

Best-effort

MP2.6.8.2

A function must not return a reference or a pointer to a local variable with automatic storage duration

Exact

MP2.6.8.3

An assignment operator shall not assign the address of an object with automatic storage duration to an object with a greater lifetime

Exact

MP2.6.8.4

Member functions returning references to their object should be ref-qualified appropriately

Exact

MP2.6.9.1

The same type aliases shall be used in all declarations of the same entity

Exact

MP2.6.9.2

The names of the standard signed integer types and standard unsigned integer types should not be used

Exact

MP2.7.0.1

There shall be no conversion from type bool

Exact

MP2.7.0.2

There shall be no conversion to type bool

Exact

MP2.7.0.3

The numerical value of a character shall not be used

Exact

MP2.7.0.4

The operands of bitwise operators and shift operators shall be appropriate

Safe

MP2.7.0.5

Integral promotion and the usual arithmetic conversions shall not change the signedness or the type category of an operand

Exact

MP2.7.0.6

Assignment between numeric types shall be appropriate

Exact

MP2.7.11.1

nullptr shall be the only form of the null-pointer-constant

Exact

MP2.7.11.2

An array passed as a function argument shall not decay to a pointer

Exact

MP2.7.11.3

A conversion from function type to pointer-to-function type shall only occur in appropriate contexts

Best-effort

MP2.8.0.1

Parentheses should be used to make the meaning of an expression appropriately explicit

Exact

MP2.8.1.1

A non-transient lambda shall not implicitly capture this

Exact

MP2.8.1.2

Variables should be captured explicitly in a non-transient lambda

Safe

MP2.8.2.1

A virtual base class shall only be cast to a derived class by means of dynamic_cast

Exact

MP2.8.2.2

C-style casts and functional notation casts shall not be used

Exact

MP2.8.2.3

A cast shall not remove any const or volatile qualification from the type accessed via a pointer or by reference

Exact

MP2.8.2.4

Casts shall not be performed between a pointer to function and any other type

Exact

MP2.8.2.5

reinterpret_cast shall not be used

Exact

MP2.8.2.6

An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type

Exact

MP2.8.2.7

A cast should not convert a pointer type to an integral type

Exact

MP2.8.2.8

An object pointer type shall not be cast to an integral type other than std::uintptr_t or std::intptr_t

Exact

MP2.8.2.9

The operand to typeid shall not be an expression of polymorphic class type

Exact

MP2.8.2.10

Functions shall not call themselves, either directly or indirectly

Complete

MP2.8.2.11

An argument passed via ellipsis shall have an appropriate type

Exact

MP2.8.3.1

The built-in unary - operator should not be applied to an expression of unsigned type

Exact

MP2.8.3.2

The built-in unary + operator should not be used

Exact

MP2.8.7.1

Pointer arithmetic shall not form an invalid pointer

Best-effort

MP2.8.7.2

Subtraction between pointers shall only be applied to pointers that address elements of the same array

Complete

MP2.8.9.1

The built-in relational operators >, >=, < and <= shall not be applied to objects of pointer type, except where they point to elements of the same array

Complete

MP2.8.14.1

The right-hand operand of a logical && or || operator should not contain persistent side effects

Safe

MP2.8.18.1

An object or subobject must not be copied to an overlapping object

Best-effort

MP2.8.18.2

The result of an assignment operator should not be used

Exact

MP2.8.19.1

The comma operator should not be used

Exact

MP2.8.20.1

An unsigned arithmetic operation with constant operands should not wrap

Exact

MP2.9.2.1

An explicit type conversion shall not be an expression statement

Exact

MP2.9.3.1

The body of an iteration-statement or a selection-statement shall be a compound-statement

Exact

MP2.9.4.1

All if ... else if constructs shall be terminated with an else statement

Exact

MP2.9.4.2

The structure of a switch statement shall be appropriate

Exact

MP2.9.5.1

Legacy for statements should be simple

Safe

MP2.9.5.2

A for-range-initializer shall contain at most one function call

Exact

MP2.9.6.1

The goto statement should not be used

Exact

MP2.9.6.2

A goto statement shall reference a label in a surrounding block

Exact

MP2.9.6.3

The goto statement shall jump to a label declared later in the function body

Exact

MP2.9.6.4

A function declared with the [[noreturn]] attribute shall not return

Precise

MP2.9.6.5

A function with non-void return type shall return a value on all paths

Exact

MP2.10.0.1

A declaration should not declare more than one variable or member variable

Exact

MP2.10.1.1

The target type of a pointer or lvalue reference parameter should be const-qualified appropriately

Exact

MP2.10.1.2

The volatile qualifier shall be used appropriately

Exact

MP2.10.2.1

An enumeration shall be defined with an explicit underlying type

Exact

MP2.10.2.2

Unscoped enumerations should not be declared

Exact

MP2.10.2.3

The numeric value of an unscoped enumeration with no fixed underlying type shall not be used

Exact

MP2.10.3.1

There should be no unnamed namespaces in header files

Exact

MP2.10.4.1

The asm declaration shall not be used

Exact

MP2.11.3.1

Variables of array type should not be declared

Exact

MP2.11.3.2

The declaration of an object should contain no more than two levels of pointer indirection

Exact

MP2.11.6.1

All variables should be initialized

Exact

MP2.11.6.2

The value of an object must not be read before it has been set

Best-effort

MP2.11.6.3

Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique

Exact

MP2.12.2.1

Bit-fields should not be declared

Exact

MP2.12.2.2

A bit-field shall have an appropriate type

Exact

MP2.12.2.3

A named bit-field with signed integer type shall not have a length of one bit

Exact

MP2.12.3.1

The union keyword shall not be used

Exact

MP2.13.1.1

Classes should not be inherited virtually

Exact

MP2.13.1.2

An accessible base class shall not be both virtual and non-virtual in the same hierarchy

Exact

MP2.13.3.1

User-declared member functions shall use the virtual, override and final specifiers appropriately

Exact

MP2.13.3.2

Parameters in an overriding virtual function shall not specify different default arguments

Exact

MP2.13.3.3

The parameters in all declarations or overrides of a function shall either be unnamed or have identical names

Exact

MP2.13.3.4

A comparison of a potentially virtual pointer to member function shall only be with nullptr

Exact

MP2.14.1.1

Non-static data members should be either all private or all public

Exact

MP2.15.0.2

User-provided copy and move member functions of a class should have appropriate signatures

Exact

MP2.15.1.1

An object’s dynamic type shall not be used from within its constructor or destructor

Complete

MP2.15.1.2

All constructors of a class should explicitly initialize all of its virtual base classes and immediate base classes

Exact

MP2.15.1.3

Conversion operators and constructors that are callable with a single argument shall be explicit

Exact

MP2.15.1.4

All direct, non-static data members of a class should be initialized before the class object is accessible

Exact

MP2.16.5.1

The logical AND and logical OR operators shall not be overloaded

Exact

MP2.16.5.2

The address-of operator shall not be overloaded

Exact

MP2.16.6.1

Symmetrical operators should only be implemented as non-member functions

Exact

MP2.17.8.1

Function templates shall not be explicitly specialized

Exact

MP2.18.1.1

An exception object shall not have pointer type

Exact

MP2.18.1.2

An empty throw shall only occur within the compound-statement of a catch handler

Exact

MP2.18.3.1

There should be at least one exception handler to catch all otherwise unhandled exceptions

Exact

MP2.18.3.2

An exception of class type shall be caught by const reference or reference

Exact

MP2.18.3.3

Handlers for a function-try-block of a constructor or destructor shall not refer to non-static members from their class or its bases

Exact

MP2.18.4.1

Exception-unfriendly functions shall be noexcept

Exact

MP2.18.5.1

A noexcept function should not attempt to propagate an exception to the calling function

Complete

MP2.18.5.2

Program-terminating functions should not be used

Exact

MP2.19.0.1

A line whose first token is # shall be a valid preprocessing directive

Exact

MP2.19.0.2

Function-like macros shall not be defined

Exact

MP2.19.0.3

#include directives should only be preceded by preprocessor directives or comments

Exact

MP2.19.0.4

#undef should only be used for macros defined previously in the same file

Exact

MP2.19.1.1

The defined preprocessor operator shall be used appropriately

Exact

MP2.19.1.2

All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Exact

MP2.19.1.3

All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be defined prior to evaluation

Exact

MP2.19.2.1

Precautions shall be taken in order to prevent the contents of a header file being included more than once

Exact

MP2.19.2.2

The #include directive shall be followed by either a <filename> or "filename" sequence

Exact

MP2.19.2.3

The ' or " or \ characters and the /* or // character sequences shall not occur in a header file name

Exact

MP2.19.3.1

The # and ## preprocessor operators should not be used

Exact

MP2.19.3.2

A macro parameter immediately following a # operator shall not be immediately followed by a ## operator

Exact

MP2.19.3.3

The argument to a mixed-use macro parameter shall not be subject to further expansion

Exact

MP2.19.3.4

Parentheses shall be used to ensure macro arguments are expanded appropriately

Exact

MP2.19.3.5

Tokens that look like a preprocessing directive shall not occur within a macro argument

Exact

MP2.19.6.1

The #pragma directive and the _Pragma operator should not be used

Exact

MP2.21.2.1

The library functions atof, atoi, atol and atoll from <cstdlib>shall not be used

Exact

MP2.21.2.2

The string handling functions from <cstring>, <cstdlib>, <cwchar> and <cinttypes> shall not be used

Exact

MP2.21.2.3

The library function system from <cstdlib> shall not be used

Exact

MP2.21.2.4

The macro offsetof shall not be used

Exact

MP2.21.6.1

Dynamic memory should not be used

Safe

MP2.21.6.2

Dynamic memory shall be managed automatically

Safe

MP2.21.6.3

Advanced memory management shall not be used

Exact

MP2.21.6.4

If a project defines either a sized or unsized version of a global operator delete, then both shall be defined

Exact

MP2.21.6.5

A pointer to an incomplete class type shall not be deleted

Exact

MP2.21.10.1

The features of <cstdarg> shall not be used

Exact

MP2.21.10.2

The standard header file <csetjmp> shall not be used

Exact

MP2.21.10.3

The facilities provided by the standard header file <csignal> shall not be used

Exact

MP2.22.3.1

The assert macro shall not be used with a constant-expression

Exact

MP2.22.4.1

The literal value zero shall be the only value assigned to errno

Exact

MP2.23.11.1

The raw pointer constructors of std::shared_ptr and std::unique_ptr should not be used

Exact

MP2.24.5.1

The character handling functions from <cctype> and <cwctype> shall not be used

Exact

MP2.24.5.2

The C++ Standard Library functions memcpy, memmove and memcmp from <cstring> shall not be used

Exact

MP2.25.5.1

The setlocale and std::locale::global functions shall not be called

Exact

MP2.25.5.2

The pointers returned by the C++ Standard Library functions localeconv, getenv, setlocale or strerror must only be used as if they have pointer to const-qualified type

Exact

MP2.25.5.3

The pointer returned by the C++ Standard Library functions asctime, ctime, gmtime, localtime, localeconv, getenv, setlocale or strerror must not be used following a subsequent call to the same function

Safe

MP2.26.3.1

std::vector should not be specialized with bool

Exact

MP2.28.3.1

Predicates shall not have persistent side effects

Safe

MP2.28.6.1

The argument to std::move shall be a non-const lvalue

Exact

MP2.28.6.2

Forwarding references and std::forward shall be used together

Safe

MP2.28.6.3

An object shall not be used while in a potentially moved-from state

Exact

MP2.28.6.4

The result of std::remove, std::remove_if, std::unique and empty shall be used

Exact

MP2.30.0.1

The C Library input/output functions shall not be used

Exact

MP2.30.0.2

Reads and writes on the same file stream shall be separated by a positioning operation

Safe

MISRA C++:2023 Guideline Enforcement Plans

The following table presents a template for Guideline Enforcement Plans (GEPs) provided by this version of ECLAIR for the MISRA C++:2023 coding standard [56].

The table adopts the following conventions:

  • The Guideline column contains the guideline identifier along with its main attributes: its strictness category (Mandatory, Required or Advisory) and, for rules, its decidability (Decidable or Undecidable) and scope (System or Single Translation Unit, the latter abbreviated Single T.U.).

  • The Compliant ECLAIR outcome column contains the ECLAIR requirements for compliance for this guideline.

  • The Required additional activities column gives any additional activities needed for full compliance.

Note that, for each guideline, the following procedure should be adopted:

  • perform all activities labeled by before in the Required additional activities column;

  • run the ECLAIR analysis with this guideline enabled;

  • check that the requirements for compliance for this guideline in the Compliant ECLAIR outcome are met;

  • perform all activities labeled by after in the Required additional activities column.

For any guideline where the Compliant ECLAIR outcome column is empty, just perform all activities in the Required additional activities column.

GEP for supported MISRA C++:2023 guidelines

Guideline

Compliant ECLAIR outcome

Required additional activities

Rule 0.0.1
Required
Decidable
Single T.U.

no violation report for MP2.0.0.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 0.0.2
Advisory
Undecidable
System

no violation report for MP2.0.0.2

after: obtain 100% branch coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 0.1.1
Advisory
Undecidable
System

no violation report or caution report for MP2.0.1.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 0.1.2
Required
Decidable
Single T.U.

no violation report for MP2.0.1.2

Rule 0.2.1
Advisory
Decidable
Single T.U.

no violation report for MP2.0.2.1

Rule 0.2.2
Required
Decidable
Single T.U.

no violation report for MP2.0.2.2

Rule 0.2.3
Advisory
Decidable
Single T.U.

conduct a manual review to ensure compliance to the guideline

Rule 0.2.4
Advisory
Decidable
System

no violation report for MP2.0.2.4

Dir 0.3.1
Advisory

no violation report for MP2.0.3.1

after: check all reported uses of floating-point arithmetic for the used compiler and target hardware

Dir 0.3.2
Required
Undecidable
System

conduct a manual review to ensure compliance to the guideline

Rule 4.1.1
Required
Undecidable
System

no violation report for MP2.4.1.1

before: specify using the behavior configuration of the related ancillary services any deviations from the standard;
after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 4.1.2
Advisory
Decidable
Single T.U.

no violation report for MP2.4.1.2

Rule 4.1.3
Required
Undecidable
System

no violation report or caution report for MP2.4.1.3

before: ensure that the program does not give rise to any undefined or critical unspecified behaviors;
after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 4.6.1
Required
Undecidable
System

no violation report or caution report for MP2.4.6.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 5.0.1
Advisory
Decidable
Single T.U.

no violation report for MP2.5.0.1

Rule 5.7.1
Required
Decidable
Single T.U.

no violation report for MP2.5.7.1

Dir 5.7.2
Advisory
Decidable
Single T.U.

no violation report for MP2.5.7.2

after: check for any residual unreported commented out code

Rule 5.7.3
Required
Decidable
Single T.U.

no violation report for MP2.5.7.3

Rule 5.10.1
Required
Decidable
Single T.U.

no violation report for MP2.5.10.1

Rule 5.13.1
Required
Decidable
Single T.U.

no violation report for MP2.5.13.1

Rule 5.13.2
Required
Decidable
Single T.U.

no violation report for MP2.5.13.2

Rule 5.13.3
Required
Decidable
Single T.U.

no violation report for MP2.5.13.3

Rule 5.13.4
Required
Decidable
Single T.U.

no violation report for MP2.5.13.4

Rule 5.13.5
Required
Decidable
Single T.U.

no violation report for MP2.5.13.5

Rule 5.13.6
Required
Decidable
Single T.U.

no violation report for MP2.5.13.6

Rule 5.13.7
Required
Decidable
Single T.U.

no violation report for MP2.5.13.7

Rule 6.0.1
Required
Decidable
Single T.U.

no violation report for MP2.6.0.1

Rule 6.0.2
Advisory
Decidable
Single T.U.

no violation report for MP2.6.0.2

Rule 6.0.3
Advisory
Decidable
Single T.U.

no violation report for MP2.6.0.3

Rule 6.0.4
Required
Decidable
Single T.U.

no violation report for MP2.6.0.4

Rule 6.2.1
Required
Decidable
System

no violation report or caution report for MP2.6.2.1

Rule 6.2.2
Required
Decidable
System

no violation report for MP2.6.2.2

Rule 6.2.3
Required
Decidable
System

no violation report or caution report for MP2.6.2.3

Rule 6.2.4
Required
Decidable
Single T.U.

no violation report for MP2.6.2.4

Rule 6.4.1
Required
Decidable
Single T.U.

no violation report for MP2.6.4.1

Rule 6.4.2
Required
Decidable
Single T.U.

conduct a manual review to ensure compliance to the guideline

Rule 6.4.3
Required
Decidable
Single T.U.

conduct a manual review to ensure compliance to the guideline

Rule 6.5.1
Advisory
Decidable
Single T.U.

no violation report for MP2.6.5.1

Rule 6.5.2
Advisory
Decidable
Single T.U.

no violation report for MP2.6.5.2

Rule 6.7.1
Required
Decidable
Single T.U.

no violation report for MP2.6.7.1

Rule 6.7.2
Required
Decidable
Single T.U.

no violation report for MP2.6.7.2

Rule 6.8.1
Required
Undecidable
System

no violation report for MP2.6.8.1

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 6.8.2
Mandatory
Decidable
Single T.U.

no violation report for MP2.6.8.2

Rule 6.8.3
Required
Decidable
Single T.U.

no violation report for MP2.6.8.3

Rule 6.8.4
Advisory
Decidable
Single T.U.

no violation report for MP2.6.8.4

Rule 6.9.1
Required
Decidable
Single T.U.

no violation report for MP2.6.9.1

Rule 6.9.2
Advisory
Decidable
Single T.U.

no violation report for MP2.6.9.2

Rule 7.0.1
Required
Decidable
Single T.U.

no violation report for MP2.7.0.1

Rule 7.0.2
Required
Decidable
Single T.U.

no violation report for MP2.7.0.2

Rule 7.0.3
Required
Decidable
Single T.U.

no violation report for MP2.7.0.3

Rule 7.0.4
Required
Decidable
Single T.U.

no violation report for MP2.7.0.4

Rule 7.0.5
Required
Decidable
Single T.U.

no violation report for MP2.7.0.5

Rule 7.0.6
Required
Decidable
Single T.U.

no violation report for MP2.7.0.6

Rule 7.11.1
Required
Decidable
Single T.U.

no violation report for MP2.7.11.1

Rule 7.11.2
Required
Decidable
Single T.U.

no violation report for MP2.7.11.2

Rule 7.11.3
Required
Decidable
Single T.U.

no violation report for MP2.7.11.3

after: obtain 100% statement coverage with a test suite or conduct a manual review to ensure compliance to the guideline

Rule 8.0.1
Advisory
Decidable
Single T.U.

no violation report for MP2.8.0.1

Rule 8.1.1
Required
Decidable
Single T.U.

no violation report for MP2.8.1.1

Rule 8.1.2
Advisory
Decidable
Single T.U.

no violation report or caution report for MP2.8.1.2

after: when it is known that a lambda is transient, false positive reports related to captures in that lambda can be deviated as described in the service documentation

Rule 8.2.1
Required
Decidable
Single T.U.

no violation report for MP2.8.2.1

Rule 8.2.2
Required
Decidable
Single T.U.

no violation report for MP2.8.2.2

Rule 8.2.3
Required
Decidable
Single T.U.

no violation report for MP2.8.2.3

Rule 8.2.4
Required
Decidable
Single T.U.

no violation report for MP2.8.2.4

Rule 8.2.5
Required
Decidable
Single T.U.

no violation report for MP2.8.2.5

Rule 8.2.6
Required
Decidable
Single T.U.

no violation report for MP2.8.2.6

Rule 8.2.7
Advisory
Decidable
Single T.U.

no violation report for MP2.8.2.7

Rule 8.2.8
Required
Decidable
Single T.U.

no violation report for MP2.8.2.8

Rule 8.2.9
Required
Decidable
Single T.U.

no violation report for MP2.8.2.9

Rule 8.2.10
Required
Undecidable
System

no violation report or caution report for MP2.8.2.10

Rule 8.2.11
Required
Decidable
Single T.U.

no violation report for MP2.8.2.11

Rule 8.3.1
Advisory
Decidable
Single T.U.

no violation report for MP2.8.3.1

Rule 8.3.2
Advisory
Decidable
Single T.U.

no violation report for MP2.8.3.2

Rule 8.7.1
Required
Undecidable
System

no violation report or caution report for MP2.8.7.1

after: pointers subject to arithmetic operations or array indexing should be checked

Rule 8.7.2
Required
Undecidable
System

no violation report or caution report for MP2.8.7.2

Rule 8.9.1
Required
Undecidable
System

no violation report or caution report for MP2.8.9.1

Rule 8.14.1
Advisory
Undecidable
System

no violation report or caution report for MP2.8.14.1

Rule 8.18.1
Mandatory
Undecidable
System

no violation report or caution report for MP2.8.18.1

after: assignments to or from objects created with some overlap in memory with another object should be checked

Rule 8.18.2
Advisory
Decidable
Single T.U.

no violation report for MP2.8.18.2

Rule 8.19.1
Advisory
Decidable
Single T.U.

no violation report for MP2.8.19.1

Rule 8.20.1
Advisory
Decidable
Single T.U.

no violation report for MP2.8.20.1

Rule 9.2.1
Required
Decidable
Single T.U.

no violation report for MP2.9.2.1

Rule 9.3.1
Required
Decidable
Single T.U.

no violation report for MP2.9.3.1

Rule 9.4.1
Required
Decidable
Single T.U.

no violation report for MP2.9.4.1

Rule 9.4.2
Required
Decidable
Single T.U.

no violation report for MP2.9.4.2

Rule 9.5.1
Advisory
Decidable
Single T.U.

no violation report or caution report for MP2.9.5.1

Rule 9.5.2
Required
Decidable
Single T.U.

no violation report for MP2.9.5.2

Rule 9.6.1
Advisory
Decidable
Single T.U.

no violation report for MP2.9.6.1

Rule 9.6.2
Required
Decidable
Single T.U.

no violation report for MP2.9.6.2

Rule 9.6.3
Required
Decidable
Single T.U.

no violation report for MP2.9.6.3

Rule 9.6.4
Required
Undecidable
System

no violation report for MP2.9.6.4

Rule 9.6.5
Required
Decidable
Single T.U.

no violation report for MP2.9.6.5

Rule 10.0.1
Advisory
Decidable
Single T.U.

no violation report for MP2.10.0.1

Rule 10.1.1
Advisory
Decidable
Single T.U.

no violation report for MP2.10.1.1

Rule 10.1.2
Required
Decidable
Single T.U.

no violation report for MP2.10.1.2

Rule 10.2.1
Required
Decidable
Single T.U.

no violation report for MP2.10.2.1

Rule 10.2.2
Advisory
Decidable
Single T.U.

no violation report for MP2.10.2.2

Rule 10.2.3
Required
Decidable
Single T.U.

no violation report for MP2.10.2.3

Rule 10.3.1
Advisory
Decidable
Single T.U.

no violation report for MP2.10.3.1

Rule 10.4.1
Required
Decidable
Single T.U.

no violation report for MP2.10.4.1

Rule 11.3.1
Advisory
Decidable
Single T.U.

no violation report for MP2.11.3.1

Rule 11.3.2
Advisory
Decidable
Single T.U.

no violation report for MP2.11.3.2

Rule 11.6.1
Advisory
Decidable
Single T.U.

no violation report for MP2.11.6.1

Rule 11.6.2
Mandatory
Undecidable
System

no violation report for MP2.11.6.2 or caution report for MP2.9.6.3

after: check every backward or sideways jumps present in the code to ensure compliance to the guideline

Rule 11.6.3
Required
Decidable
Single T.U.

no violation report for MP2.11.6.3

Rule 12.2.1
Advisory
Decidable
Single T.U.

no violation report for MP2.12.2.1

Rule 12.2.2
Required
Decidable
Single T.U.

no violation report for MP2.12.2.2

Rule 12.2.3
Required
Decidable
Single T.U.

no violation report for MP2.12.2.3

Rule 12.3.1
Required
Decidable
Single T.U.

no violation report for MP2.12.3.1

Rule 13.1.1
Advisory
Decidable
Single T.U.

no violation report for MP2.13.1.1

Rule 13.1.2
Required
Decidable
Single T.U.

no violation report for MP2.13.1.2

Rule 13.3.1
Required
Decidable
Single T.U.

no violation report for MP2.13.3.1

Rule 13.3.2
Required
Decidable
Single T.U.

no violation report for MP2.13.3.2

Rule 13.3.3
Required
Decidable
System

no violation report for MP2.13.3.3

Rule 13.3.4
Required
Decidable
Single T.U.

no violation report for MP2.13.3.4

Rule 14.1.1
Advisory
Decidable
Single T.U.

no violation report for MP2.14.1.1

Rule 15.0.1
Required
Decidable
Single T.U.

conduct a manual review to ensure compliance to the guideline

Rule 15.0.2
Advisory
Decidable
Single T.U.

no violation report for MP2.15.0.2

Rule 15.1.1
Required
Undecidable
System

no violation report or caution report for MP2.15.1.1

Rule 15.1.2
Advisory
Decidable
Single T.U.

no violation report for MP2.15.1.2

Rule 15.1.3
Required
Decidable
Single T.U.

no violation report for MP2.15.1.3

Rule 15.1.4
Advisory
Decidable
Single T.U.

no violation report for MP2.15.1.4

Rule 15.1.5
Required
Decidable
Single T.U.

conduct a manual review to ensure compliance to the guideline

Dir 15.8.1
Required

conduct a manual review to ensure compliance to the guideline

Rule 16.5.1
Required
Decidable
Single T.U.

no violation report for MP2.16.5.1

Rule 16.5.2
Required
Decidable
Single T.U.

no violation report for MP2.16.5.2

Rule 16.6.1
Advisory
Decidable
Single T.U.

no violation report for MP2.16.6.1

Rule 17.8.1
Required
Decidable
Single T.U.

no violation report for MP2.17.8.1

Rule 18.1.1
Required
Decidable
Single T.U.

no violation report for MP2.18.1.1

Rule 18.1.2
Required
Decidable
Single T.U.

no violation report for MP2.18.1.2

Rule 18.3.1
Advisory
Decidable
Single T.U.

no violation report for MP2.18.3.1

Rule 18.3.2
Required
Decidable
Single T.U.

no violation report for MP2.18.3.2

Rule 18.3.3
Required
Decidable
Single T.U.

no violation report for MP2.18.3.3

Rule 18.4.1
Required
Decidable
Single T.U.

no violation report for MP2.18.4.1

Rule 18.5.1
Advisory
Undecidable
System

no violation report or caution report for MP2.18.5.1

Rule 18.5.2
Advisory
Decidable
Single T.U.

no violation report for MP2.18.5.2

Rule 19.0.1
Required
Decidable
Single T.U.

no violation report for MP2.19.0.1

Rule 19.0.2
Required
Decidable
Single T.U.

no violation report for MP2.19.0.2

Rule 19.0.3
Advisory
Decidable
Single T.U.

no violation report for MP2.19.0.3

Rule 19.0.4
Advisory
Decidable
Single T.U.

no violation report for MP2.19.0.4

Rule 19.1.1
Required
Decidable
Single T.U.

no violation report for MP2.19.1.1

Rule 19.1.2
Required
Decidable
Single T.U.

no violation report for MP2.19.1.2

Rule 19.1.3
Required
Decidable
Single T.U.

no violation report for MP2.19.1.3

Rule 19.2.1
Required
Decidable
Single T.U.

no violation report for MP2.19.2.1

Rule 19.2.2
Required
Decidable
Single T.U.

no violation report for MP2.19.2.2

Rule 19.2.3
Required
Decidable
Single T.U.

no violation report for MP2.19.2.3

Rule 19.3.1
Advisory
Decidable
Single T.U.

no violation report for MP2.19.3.1

Rule 19.3.2
Required
Decidable
Single T.U.

no violation report for MP2.19.3.2

Rule 19.3.3
Required
Decidable
Single T.U.

no violation report for MP2.19.3.3

Rule 19.3.4
Required
Decidable
Single T.U.

no violation report for MP2.19.3.4

Rule 19.3.5
Required
Decidable
Single T.U.

no violation report for MP2.19.3.5

Rule 19.6.1
Advisory
Decidable
Single T.U.

no violation report for MP2.19.6.1

Rule 21.2.1
Required
Decidable
Single T.U.

no violation report for MP2.21.2.1

Rule 21.2.2
Required
Decidable
Single T.U.

no violation report for MP2.21.2.2

Rule 21.2.3
Required
Decidable
Single T.U.

no violation report for MP2.21.2.3

Rule 21.2.4
Required
Decidable
Single T.U.

no violation report for MP2.21.2.4

Rule 21.6.1
Advisory
Undecidable
Single T.U.

no violation report for MP2.21.6.1

before: provide a complete and accurate configuration for dynamic memory related call properties for third-party routines

Rule 21.6.2
Required
Decidable
Single T.U.

no violation report for MP2.21.6.2

Rule 21.6.3
Required
Decidable
Single T.U.

no violation report for MP2.21.6.3

Rule 21.6.4
Required
Decidable
System

no violation report for MP2.21.6.4

Rule 21.6.5
Required
Decidable
Single T.U.

no violation report for MP2.21.6.5

Rule 21.10.1
Required
Decidable
Single T.U.

no violation report for MP2.21.10.1

Rule 21.10.2
Required
Decidable
Single T.U.

no violation report for MP2.21.10.2

Rule 21.10.3
Required
Decidable
Single T.U.

no violation report for MP2.21.10.3

Rule 22.3.1
Required
Decidable
Single T.U.

no violation report for MP2.22.3.1

Rule 22.4.1
Required
Decidable
Single T.U.

no violation report for MP2.22.4.1

Rule 23.11.1
Advisory
Decidable
Single T.U.

no violation report for MP2.23.11.1

Rule 24.5.1
Required
Decidable
Single T.U.

no violation report for MP2.24.5.1

Rule 24.5.2
Required
Decidable
Single T.U.

no violation report for MP2.24.5.2

Rule 25.5.1
Required
Decidable
Single T.U.

no violation report for MP2.25.5.1

Rule 25.5.2
Mandatory
Decidable
Single T.U.

no violation report for MP2.25.5.2

Rule 25.5.3
Mandatory
Undecidable
System

no violation report or caution report for MP2.25.5.3

Rule 26.3.1
Advisory
Decidable
Single T.U.

no violation report for MP2.26.3.1

Rule 28.3.1
Required
Undecidable
System

no violation report for MP2.28.3.1

after: when a predicate known to have no side effect is reported, the property can be asserted with a configuration, as described in the service documentation, which will improve the precision of subsequent analyses

Rule 28.6.1
Required
Decidable
Single T.U.

no violation report for MP2.28.6.1

Rule 28.6.2
Required
Decidable
Single T.U.

no violation report or caution report for MP2.28.6.2

Rule 28.6.3
Required
Decidable
Single T.U.

no violation report for MP2.28.6.3

Rule 28.6.4
Required
Decidable
Single T.U.

no violation report for MP2.28.6.4

Rule 30.0.1
Required
Decidable
Single T.U.

no violation report for MP2.30.0.1

Rule 30.0.2
Required
Undecidable
System

no violation report or caution report for MP2.30.0.2

The BARR-C:2018 Rules

For the BARR-C:2018 coding standard [8], each of the supported guidelines, the identifier for the corresponding ECLAIR service is obtained by adding the prefix NC3, thereby obtaining, for example: NC3.1.1.a, NC3.5.6.b, NC3.7.1.m, …

Note that the page numbers included in the references to [8] in the ECLAIR service summaries are for the PDF version of [8] .

Rule NC3.1.1.a

Summary

All programs shall be written to comply with the C99 version of the ISO C Programming Language Standard. (See page 20 of BARR-C-2018 [8] .)

Description

All the code must conform to the C99 standard’s syntax and constraints and not exceed the implementation’s limits.

Imprecision

Cautions are reported when the behavior cannot be determined and the related ancillary service reports possible non-compliance as a caution.

This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfldtp STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.charxwde STD.cissnest STD.cmpdltrl STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptdecl STD.emptenum STD.emptinit STD.emptmarg STD.enumlist STD.extident STD.flexaray STD.forhdecl STD.freestlb STD.funojptr STD.iddiflkg STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.prepdirc STD.pteincmp STD.ptrnconv STD.ptypnest STD.qotemtch STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=NC3.1.1.a,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=NC3.1.1.a,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=NC3.1.1.a,standards=c99

Rule NC3.1.1.d

Summary

Preprocessor directive #define shall not be used to alter or rename any keyword or other aspect of the programming language. (See page 20 of BARR-C-2018 [8] .)

Description

Reports any use of the #define directive on a keyword.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=NC3.1.1.d,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=NC3.1.1.d,reserved_standard="std()"

Option macros
macros
-config=NC3.1.1.d,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option ignored_macros
ignored_macros
-config=NC3.1.1.d,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule NC3.1.2.a

Summary

The width of all lines in a program shall be limited to a maximum of 80 characters. (See page 21 of BARR-C-2018 [8] .)

Description

Reports any lines in the program that are longer than 80 characters.

The max_length service configuration can be used to change the limit.

Configuration

See generic service options.

Option max_length
max_length
-config=NC3.1.2.a,max_length=MAX

Maximum allowed number of characters in a line.

MAX:

maximum line length. It must be an integer greater than or equal to 1.

Default:

-config=NC3.1.2.a,max_length=80

Rule NC3.1.3.a

Summary

Braces shall always surround the blocks of code (a.k.a., compound statements), following if, else, switch, while, do, and for statements; single statements and empty statements following these keywords shall also always be surrounded by braces. (See page 22 of BARR-C-2018 [8] .)

Description

Reports if the body of an iteration statement or selection statement is not compound.

In an if statement:

  • the condition part must be immediately followed by a compound statement;

  • any else keyword must be followed by another if statement or by a compound statement.

Configuration

See generic service options.

Rule NC3.1.3.b

Summary

Each left brace ({) shall appear by itself on the line below the start of the block it opens. The corresponding right brace (}) shall appear by itself in the same position the appropriate number of lines later in the file. (See page 22 of BARR-C-2018 [8] .)

Description

Reports if the pair of left and right braces for a compound statement are not on a line by themselves or not indented by the same number of spaces. Note that comments following the opening and closing braces are allowed.

Configuration

See generic service options.

Rule NC3.1.4.a

Summary

Do not rely on C’s operator precedence rules, as they may not be obvious to those who maintain the code. To aid clarity, use parentheses (and/or break long statements into multiple lines of code) to ensure proper execution order within a sequence of operations. (See page 23 of BARR-C-2018 [8] .)

Description

Reports an expression if any of the following hold:

  • the operand of sizeof or _Alignof is not in parentheses;

  • the precedence P of the main operator is between 3 and 12 and the precedence of the operand is strictly greater than P and no more than 12.

Note that the following operators and their precedences (as written in the MISRA C document) are assumed:

12 Multiplicative  * / %
11 Additive        + -
10 Bitwise Shift   << >>
9  Relational      < <= > >=
8  Equality        == !=
7  Bitwise AND     &
6  Bitwise XOR     ^
5  Bitwise OR      |
4  Logical AND     &&
3  Logical OR      ||

The trusted_pairs service configuration can be used to specify report tags for selected pairs of operators where the first matches the expression’s main operator and the second matches an operator of one of its operands. For example:

-doc="Programmers are aware of the precedence between relational and arithmetic operators, no developer confusion possible."
-config=NC3.1.4.a,trusted_pairs={safe, relational:arithmetic}

will deviate reports for expressions such as a > b+c and b+c < a.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=NC3.1.4.a,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule NC3.1.4.b

Summary

Unless it is a single identifier or constant, each operand of the logical AND (&&) and logical OR (||) operators shall be surrounded by parentheses. (See page 23 of BARR-C-2018 [8] .)

Description

An operand of a logical && or || operator must be a primary expression (i.e., a single identifier, constant or parenthesized expression).

The trusted_pairs service configuration can be used to specify report tags for selected pairs of operators where the first is matches the expression’s main operator and the second matches an operator of one of its operands. For example:

-doc="Programmers are aware of the precedence between logical or operators, no developer confusion possible."
-config=NC3.1.4.b,trusted_pairs={safe, "lor:lor"}

will deviate reports for expressions such as

a || b || c

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=NC3.1.4.b,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule NC3.1.5.a

Summary

Abbreviations and acronyms should generally be avoided unless their meanings are widely and consistently understood in the engineering community. (See page 24 of BARR-C-2018 [8] .)

Description

Reports if string literals use vocabulary not in the dictionaries:

  • The context_dictionary service configuration should name an English language dictionary file.

  • The project_dictionary service configuration should name a dictionary file containing special words, acronyms,and abbreviations allowed in the project.

See vocabulary for more information about the vocabulary dictionaries and their use.

Configuration

See generic service options.

Option statements
statements
-config=NC3.1.5.a,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option project_dictionary
project_dictionary
-config=NC3.1.5.a,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=NC3.1.5.a,project_dictionary=""

Option context_dictionary
context_dictionary
-config=NC3.1.5.a,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=NC3.1.5.a,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=NC3.1.5.a,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=NC3.1.5.a,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=NC3.1.5.a,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=NC3.1.5.a,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=NC3.1.5.a,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=NC3.1.5.a,max_no_case_length=16

Option good_words_file
good_words_file
-config=NC3.1.5.a,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=NC3.1.5.a,good_words_file=""

Option bad_words_file
bad_words_file
-config=NC3.1.5.a,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=NC3.1.5.a,bad_words_file=""

Option good_items_file
good_items_file
-config=NC3.1.5.a,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=NC3.1.5.a,good_items_file=""

Option bad_items_file
bad_items_file
-config=NC3.1.5.a,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=NC3.1.5.a,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=NC3.1.5.a,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=NC3.1.5.a,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=NC3.1.5.a,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=NC3.1.5.a,bad_item_regexs={}

Option string_splitter
string_splitter
-config=NC3.1.5.a,string_splitter=SPLITTER,...

A list of regular expressions defining string literal splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:


Option contexts
contexts
-config=NC3.1.5.a,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.1.5.b

Summary

A table of project-specific abbreviations and acronyms shall be maintained in a version-controlled document. (See page 24 of BARR-C-2018 [8] .)

Description

Reports if the project does not have a file specified by the project_file service configuration.

Configuration

See generic service options.

Option project_file
project_file
-config=NC3.1.5.b,project_file=FILES,...

Files that should be in the project directory.

{FILES,…}:

file paths. Accepted members are:

  • FILE: project file path relative to the project directory.


Rule NC3.1.6.a

Summary

Each cast shall feature an associated comment describing how the code ensures proper behavior across the range of possible values on the right side. (See page 25 of BARR-C-2018 [8] .)

Description

Reports a cast expression that does not have an explanatory comment.

the cast_doc_matcher service configuration specifies a comment matcher (see the -comment_selector global configurations) that should match the comment.

The default comment selector document_cast_comments expects one of the words cast, conversion, convert, overflow, wrap (with optional common word extensions s, ed or ing) in the comment.

For example:

-doc='Comments starting with "Changes ..." are valid explanatory comments.'
-config=NC3.1.6.a,cast_doc_matcher=
"^(?:\n|.)*Changes(?:\n|.)*$ || __document_cast_comments"

adds the word Changes to the set of expected words so that the following cast will be compliant:

int f1 (int n)
{
  short m = (short) n; // Changes from int to short expected
}

Configuration

See generic service options.

Option casts
casts
-config=NC3.1.6.a,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option cast_doc_matcher
cast_doc_matcher
-config=NC3.1.6.a,cast_doc_matcher=CMNT_MATCHER

Specify compliant comments with a comment matcher.

CMNT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=NC3.1.6.a,cast_doc_matcher=__document_cast_comments

Option ignored_comments
ignored_comments
-config=NC3.1.6.a,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.1.7.a

Summary

The auto keyword shall not be used. (See page 26 of BARR-C-2018 [8] .)

Description

Reports any use of the auto storage class.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.1.7.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.1.7.b

Summary

The register keyword shall not be used. (See page 26 of BARR-C-2018 [8] .)

Description

Reports any use of the register storage class.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.1.7.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.1.7.c

Summary

It is a preferred practice to avoid all use of the goto keyword. If goto is used it shall only jump to a label declared later in the same or an enclosing block. (See page 26 of BARR-C-2018 [8] .)

Description

Reports any goto statement (indirect or direct).

Configuration

See generic service options.

Option statements
statements
-config=NC3.1.7.c,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.1.7.c,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.1.7.d

Summary

It is a preferred practice to avoid all use of the continue keyword. (See page 26 of BARR-C-2018 [8] .)

Description

Reports any continue statement.

Configuration

See generic service options.

Option statements
statements
-config=NC3.1.7.d,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.1.7.d,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.1.8.a

Summary

The static keyword shall be used to declare all functions and variables that do not need to be visible outside of the module in which they are declared. (See page 27 of BARR-C-2018 [8] .)

Description

Reports any referenced function or variable that is declared at file scope but not explicitly declared static and for which all references are in the same unit.

More specifically, reports a function or variable if all the following hold:

  • it is referenced;

  • it is declared at file scope;

  • if it is a variable with external linkage, then all references are in the same unit;

  • it is not explicitly declared static.

  • the declaration or definition is not in a public API file.

A file can be declared part of a public API using the -file_tag and -public_files global configurations. For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

functions and variables declared in files whose names match the regular expression ^my_public_header.h$ will not be reported.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.1.8.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.1.8.b

Summary

The const keyword shall be used whenever appropriate. (See page 27 of BARR-C-2018 [8] .)

Description

Any variable that is not modified must be declared const. Notes:

  • An uninitialized local variable declaration with a single assignment is reported.

  • This service only checks the AST objects; it does not check if a macro defining a numerical constant could be replaced by a const object (See item b.iv, page 27 of BARR-C:2018 [8] ).

  • To restrict the declarations that are shown, use the show_declarations service configuration.

For example, the following configure line will restrict the reporting to variable definitions:

-doc="Report only variable definitions."
-config=NC3.1.8.b,show_declarations,none

Imprecision

False negatives are present because the single unit analyzer does not check variables with program scope.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=NC3.1.8.b,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=NC3.1.8.b,show_declarations=all

Option declarations
declarations
-config=NC3.1.8.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=NC3.1.8.b,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=NC3.1.8.b,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.2.1.a

Summary

Single-line comments in the C++ style (i.e., preceded by //) are a useful and acceptable alternative to traditional C style comments (i.e., /* ... */). (See page 29 of BARR-C-2018 [8] .)

Description

Reports as a caution the use of the /**/ comment style for a one-line comment.

Imprecision

Cautions are reported for every suspect case found.

Configuration

See generic service options.

Option comments
comments
-config=NC3.2.1.a,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=NC3.2.1.a,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.2.1.b

Summary

Comments shall never contain the preprocessor tokens /*, //, or \. (See page 29 of BARR-C-2018 [8] .)

Description

Reports:

  • any use of the character sequence /* inside any comments,

  • any use of the character sequence // inside /* comments,

  • any use of line-splicing inside // BCPL style comments.

Configuration

See generic service options.

Option comments
comments
-config=NC3.2.1.b,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option ignored_comments
ignored_comments
-config=NC3.2.1.b,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.2.1.c

Summary

Code shall never be commented out, even temporarily. (See page 29 of BARR-C-2018 [8] .)

Description

Sections of code in the compiled files must not be commented out.

Skipped source code using the preprocessor is allowed.

Note that, by default, doxygen comments are ignored; this can be changed using the ignored_comments service configuration. For example, with the following configure line all comments will be checked:

-doc="Prevent doxygen comments from being ignored."
-config=NC3.2.1.c,+ignored_comments="none()"

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

There exists no way to distinguish code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

/* This is a comment */

Configuration

See generic service options.

Option comments
comments
-config=NC3.2.1.c,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=NC3.2.1.c,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=NC3.2.1.c,code_lines=0

Option ignored_comments
ignored_comments
-config=NC3.2.1.c,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=NC3.2.1.c,ignored_comments=__doxygen_comments

Rule NC3.2.2.a

Summary

All comments shall be written in clear and complete sentences, with proper spelling and grammar and appropriate punctuation. (See page 30 of BARR-C-2018 [8] .)

Description

Checks that:

  • comments do not begin with a lowercase letter;

  • comments end with a sentence terminator (full-stop, exclamation mark or question mark);

  • each sentence terminator in the comment is not followed by a lowercase letter.

  • comments only use words in the specified vocabulary.

Note that to check the vocabulary, two files must be specified:

  • a context_dictionary service configuration naming an English language dictionary file, and

  • a project_dictionary service configuration naming a dictionary file containing special words, acronyms,and abbreviations allowed in the project.

See vocabulary for more information about the vocabulary dictionaries and their use.

Note that for this rule, a comment refers to a sequence of BCPL comment lines with no separating blank lines or a single C-style comment.

Configuration

See generic service options.

Option comments
comments
-config=NC3.2.2.a,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option project_dictionary
project_dictionary
-config=NC3.2.2.a,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=NC3.2.2.a,project_dictionary=""

Option context_dictionary
context_dictionary
-config=NC3.2.2.a,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=NC3.2.2.a,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=NC3.2.2.a,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=NC3.2.2.a,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=NC3.2.2.a,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=NC3.2.2.a,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=NC3.2.2.a,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=NC3.2.2.a,max_no_case_length=16

Option good_words_file
good_words_file
-config=NC3.2.2.a,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=NC3.2.2.a,good_words_file=""

Option bad_words_file
bad_words_file
-config=NC3.2.2.a,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=NC3.2.2.a,bad_words_file=""

Option good_items_file
good_items_file
-config=NC3.2.2.a,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=NC3.2.2.a,good_items_file=""

Option bad_items_file
bad_items_file
-config=NC3.2.2.a,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=NC3.2.2.a,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=NC3.2.2.a,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=NC3.2.2.a,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=NC3.2.2.a,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=NC3.2.2.a,bad_item_regexs={}

Option comment_regexs
comment_regexs
-config=NC3.2.2.a,comment_regexs=SPLITTER,...

A list of regular expressions defining comment splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

  • SPLITTER: regular expression defining a custom splitter.


Option ignored_comments
ignored_comments
-config=NC3.2.2.a,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option verbatim
verbatim
-config=NC3.2.2.a,verbatim=WORDS,...

Words to be written verbatim, matching case.

{WORDS,…}:

words to be written verbatim. Accepted members are:

  • WORD: verbatim word.

Default:

-config=NC3.2.2.a,verbatim=geantV

Option abbreviation
abbreviation
-config=NC3.2.2.a,abbreviation=WORDS,...

Abbreviations whose terminating . is not necessarily terminating a sentence.

{WORDS,…}:

abbreviation words. Accepted members are:

  • WORD: abbreviation word.

Default:

-config=NC3.2.2.a,abbreviation=etc, eg, e.g, no

Rule NC3.2.2.b

Summary

The most useful comments generally precede a block of code that performs one step of a larger algorithm. (See page 30 of BARR-C-2018 [8] .)

Description

Reports a block of code that does not have an explanatory comment before the block. The comment must be aligned with the code.

The stmt_document_selector service configuration can suppress the expressions checked and, for those not suppressed, specify the comment’s expected position relative to an associated expression.

The selection of explanatory comments depends on a comment matcher (see the -comment_selector global configuration):

  • All the single comments immediately before the targeted expression and not separated by a blank line are assumed to contribute to the full documentation for the expression. Hence, before the comments are checked the initial and terminating comment markers //, /* and */ are removed and the resulting texts are merged.

  • the stmt_doc_matcher service configuration specifies a comment matcher that should match the merged comment text. The default selector document_any_comments will match any merged comment.

Reports for statements that have the comments in a non-compliant position can be tagged by means of the stmt_document_selector service configuration. For example, the following configure line deviates any reports concerning the comments that are at the end of an else if block with the tag safe:

-doc="Comments at the end of an else if block are allowed."
-config=NC3.2.2.b,stmt_document_selector={safe, "stmt_child(node(if_stmt), else)", "node(if_stmt)", "end_node"}
/* check i == 1 */
if(i==1)
  {}
else if(i==2)
  {}
/* check i == 2 */

Note: rule 2.2.b as reported in the standard requires that a blank line shall follow the code block. This overlaps with rule 3.3.b checked by service NC3.3.3.b. For this reason, we consider it an oversight of the source and do not check it in this service. The blank line can be checked by using the service NC3.3.3.b.

Configuration

See generic service options.

Option stmt_doc_matcher
stmt_doc_matcher
-config=NC3.2.2.b,stmt_doc_matcher=CMNT_MATCHER

Specify the metric with a comment matcher.

CMNT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=NC3.2.2.b,stmt_doc_matcher=__document_any_comments

Option stmt_document_selector
stmt_document_selector
-config=NC3.2.2.b,stmt_document_selector={TAGS, CTXT, STMT, WHERE},...

Specifies the report tags for undocumented statements.

The configuration’s content is list of tagged statement and context matchers with a flag to indicate where the documentation is placed relative to the statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

STMT:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.

WHERE:

where documentation is placed. Accepted values are:

  • above_node: above the node;

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;


Option statements
statements
-config=NC3.2.2.b,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option ignored_comments
ignored_comments
-config=NC3.2.2.b,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.2.2.d

Summary

The number and length of individual comment blocks shall be proportional to the complexity of the code they describe. (See page 30 of BARR-C-2018 [8] .)

Description

Reports any non-trivial function definition that does not have the expected number and length of comments.

The trivial_body service configuration can be used to provide conditions (which may use any of the metrics itemized below) for functions with trivial bodies to be suppressed.

The expected number and size of the comments is specified in the form of arithmetic expressions whose variables can be any of the metrics:

The default expression for the expected number of comments is

num(max(max(0.2*(B.NAMED_PARAM_FUNC + B.STATL_FUNC) + 0.1*B.STATNL_FUNC, 0.1*B.HARRISON_FUNC), (1 + sign(B.LSLOCS_FUNC-5))/2))

and for the expected size (the number of characters in the comments)

size((8 + min(4, (B.NAMED_PARAM_FUNC + B.STATL_FUNC+B.STATNL_FUNC)/3))*B.LSLOCS_FUNC*((1 + sign(B.LSLOCS_FUNC - 5)/2)))

The decl_document_selector service configuration can specify alternative expressions.

The selection of comments depends on the replacer (see the -replacer global configuration):

  • replacer fundefn_comment_repl selects and replaces each single comment that can contribute to the full documentation for the targeted function definition; the default value for this replacer will remove the initial and terminating comment markers //, /* and */ and merge the resulting texts into a single comment.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=NC3.2.2.d,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option decl_document_selector
decl_document_selector
-config=NC3.2.2.d,decl_document_selector={TAGS, CTXT, DECL, CONSTR, WHERE},...

Specifies the report tags for undocumented declarations.

The configuration’s content is list of tagged declaration and context matchers with indicators.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONSTR:

number and size constraints. Accepted forms are:

  • LIM: number or size constraint

  • LIM&&LIMS: the comments satisfy LIM and LIMS

LIM

accepted forms are:

  • num(EXPR): the minimum number of comments is specified by EXPR

  • size(EXPR): the minimum number of characters in the comments is specified by EXPR

EXPR

accepted forms are:

  • STRING: arithmetic expression whose variables are metrics

WHERE:

specifies where the explanatory comments are supposed to be found. Accepted values are:

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;

  • doxygen: doxygen-style comments;


Option declarations
declarations
-config=NC3.2.2.d,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option trivial_body
trivial_body
-config=NC3.2.2.d,trivial_body={DECL, CONDS},...

Specify conditions for a trivial function body.

The configuration’s content is a list of declaration matchers and conditions for a trivial function body.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONDS:

trivial conditions.

Default:

-config=NC3.2.2.d,trivial_body={"node(function_defn)",
    "metric(B.LSLOCS_FUNC, 6)||empty_body()"},
  {"any()",
    "empty_body()"}

Rule NC3.2.2.h

Summary

Each module and function shall be commented in a manner suitable for automatic documentation generation, e.g., via Doxygen. (See page 30 of BARR-C-2018 [8] .)

Description

The code must use valid doxygen comments.

Note that all parameters should be documented with a separate \param description.

The doxygen_text_regex service configuration can be used to suppress the report for the specified doxygen command with text matching the regular expression.

For example, the following configure line deviates any report for a doxygen return comment matching ^[ ]*[Nn]one:

-doc='"None" is a valid doxygen return comment.'
-config=NC3.2.2.h,doxygen_text_regex= {safe, return, "^[ ]*[Nn]one"}

Configuration

See generic service options.

Option doxygen_text_regex
doxygen_text_regex
-config=NC3.2.2.h,doxygen_text_regex={TAGS, COMMAND, REGEX},...

Specify tags for commands with the matching doxygen lines.

The configuration’s content is a tuple with three terms: a report tag, a doxygen command and a regular expression.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMAND:

doxygen command. Accepted values are:

  • return: return command;

  • param: param command;

  • tparam: tparam command;

  • unknown: unknown command;

  • union: union command;

  • struct: struct command;

  • class: class command;

  • function: function command;

  • callback: callback command;

  • brief: brief command;

  • deprecated: deprecated command;

REGEX:

if the text following COMMAND matches REGEX, then any report will be tagged by TAG.


Rule NC3.3.1.a

Summary

Each of the keywords if, else, while, for, switch, and return shall always be followed by one space when there is additional program text on the same line. (See page 33 of BARR-C-2018 [8] .)

Description

There must be a single space or a newline after each of the keywords if, while, for, switch, and return.

Configuration

See generic service options.

Rule NC3.3.1.b

Summary

Each of the assignment operators =, +=, -=, *=, /=, %=, &=, |=, ^=, ~=, and != shall always be preceded and followed by one space. (See page 33 of BARR-C-2018 [8] .)

Description

There must be at least one space before the assignment operators and a single space or newline after the assignment operators.

Configuration

See generic service options.

Rule NC3.3.1.c

Summary

Each of the binary operators +, -, *, /, %, <, <=, >, >=, ==, !=, <<, >>, &, |, ^, && and || shall always be preceded and followed by one space. (See page 33 of BARR-C-2018 [8] .)

Description

There must be a single space or newline before and after the binary arithmetic, shift, relational, equality, bitwise and logical operators.

Configuration

See generic service options.

Rule NC3.3.1.d

Summary

Each of the unary operators +, -, ++, --, ! and ~, shall be written without a space on the operand side. (See page 33 of BARR-C-2018 [8] .)

Description

There must be no space:

  • after the prefix operators ++ or --;

  • before the postfix operators ++ or --;

  • after the unary prefix operators + or -;

  • after the logical negation operator ! or bitwise complement operator ~.

Configuration

See generic service options.

Rule NC3.3.1.e

Summary

The pointer operators * and & shall be written with white space on each side within declarations but otherwise without a space on the operand side. (See page 33 of BARR-C-2018 [8] .)

Description

  • Declarator operators & and *:

    • should be preceded by some white space or a left parenthesis;

    • should be followed by some white space, a right parenthesis or comma.

  • The address-of & and dereference * operators must not be followed by a space character.

The consecutive_operators service configuration can be used to specify operators that, when occuring consecutively, do not require any separating space.

For example, the following configure line allows consecutive occurrences of the pointer operator * to be written without a separating space:

-doc="Consecutive occurrences of the pointer operator can be written without any space."
-config=NC3.3.1.e,consecutive_operators="star"

Configuration

See generic service options.

Option consecutive_operators
consecutive_operators
-config=NC3.3.1.e,consecutive_operators=CHAR_TAG

Specify characters, such as an operator, keyword or bracket, that, when it occurs consecutively, it does not require any separating space.

CHAR_TAG:

one or more character tags separated by ||. Accepted forms are:

  • OPERATOR_TAG: operator tag

  • BRACK_TAG: parenthesis or square bracket tag

  • KEYWORD_TAG: keyword

  • MARKER_TAG: semicolon terminating a statement or a comma separating parameter declarations

  • OTHER_TAG: other characters

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator

BRACK_TAG

accepted forms are:

  • lbrack: left bracket of array subscript expression

  • rbrack: right bracket of array subscript expression

  • lparen: left parenthesis of a parenthesised expression

  • rparen: right parenthesis of a parenthesised expression

MARKER_TAG

accepted forms are:

  • parameter_comma: comma separating function parameters

  • semicolon: semicolon terminating a statement

OTHER_TAG

accepted forms are:

  • question: ? sigil in a conditional_operator

  • colon: : sigil in a conditional_operator

  • star: * pointer operator

  • ampersand: & pointer operator

KEYWORD_TAG

accepted forms are:

  • for: for keyword

  • while: while keyword

  • switch: switch keyword

  • return: switch keyword


Rule NC3.3.1.f

Summary

The ? and : characters that comprise the ternary operator shall each always be preceded and followed by one space. (See page 33 of BARR-C-2018 [8] .)

Description

There must be a single space or newline before and after the conditional operators ? and :.

Configuration

See generic service options.

Rule NC3.3.1.g

Summary

The structure pointer and structure member operators (-> and ., respectively) shall always be without surrounding spaces. (See page 33 of BARR-C-2018 [8] .)

Description

There must be no white space before or after the structure or union member operators -> or .

Configuration

See generic service options.

Rule NC3.3.1.h

Summary

The left and right brackets of the array subscript operator ([ and ]) shall be without surrounding spaces, except as required by another white space rule. (See page 33 of BARR-C-2018 [8] .)

Description

There must be no white space before the right and left bracket of an array subscript expression, and no white space after the left bracket.

Note that there is no check for space after the right bracket as that may conflict with other NC3 white space rules.

Configuration

See generic service options.

Rule NC3.3.1.i

Summary

Expressions within parentheses shall always have no spaces adjacent to the left and right parenthesis characters. (See page 33 of BARR-C-2018 [8] .)

Description

There must be no white space before the right and after the left parenthesis of a parenthesized expression.

Configuration

See generic service options.

Rule NC3.3.1.j

Summary

The left and right parentheses of the function call operator shall always be without surrounding spaces, except that the function declaration shall feature one space between the function name and the left parenthesis to allow that one particular mention of the function name to be easily located. (See page 33 of BARR-C-2018 [8] .)

Description

The spaces allowed before and after a function call must be as follows:

  • the left parenthesis must not be preceded or followed by any space character;

  • the right parenthesis must not be preceded by any space character.

The spaces allowed before and after a function declaration must be as follows:

  • the left parenthesis must not be preceded or followed by any space character;

  • the right parenthesis must not be preceded by any space character.

The spaces allowed before and after a function definition must be as follows:

  • the left parenthesis must be preceded by a single space and must not be followed by any space character;

  • the right parenthesis must not be preceded by any space character.

Configuration

See generic service options.

Rule NC3.3.1.k

Summary

Except when at the end of a line, each comma separating function parameters shall always be followed by one space. (See page 33 of BARR-C-2018 [8] .)

Description

There must be a single space or newline after each comma separating parameter declarations.

Configuration

See generic service options.

Rule NC3.3.1.l

Summary

Each semicolon separating the elements of a for statement shall always be followed by one space. (See page 34 of BARR-C-2018 [8] .)

Description

There must be a single space or newline after each of the semicolons in the head of a for_stmt.

An exception to this is the loop idiom for(;;).

Configuration

See generic service options.

Rule NC3.3.1.m

Summary

Each semicolon shall follow the statement it terminates without a preceding space. (See page 34 of BARR-C-2018 [8] .)

Description

There must be no space before the semicolon at the end of a statement.

Configuration

See generic service options.

Rule NC3.3.2.a

Summary

The names of variables within a series of declarations shall have their first characters aligned. (See page 35 of BARR-C-2018 [8] .)

Description

Variable declarations with file scope or in the same block of related declarations and whose names are not aligned are reported.

Declarations separated by one or more blank lines are considered to be in distinct blocks.

Configuration

See generic service options.

Rule NC3.3.2.b

Summary

The names of struct and union members shall have their first characters aligned. (See page 35 of BARR-C-2018 [8] .)

Description

Member declarations within a record or class declaration, in the same block of related declarations and whose names are not aligned are reported.

Declarations separated by one or more blank lines are considered to be in distinct blocks.

Configuration

See generic service options.

Rule NC3.3.2.c

Summary

The assignment operators within a block of adjacent assignment statements shall be aligned. (See page 35 of BARR-C-2018 [8] .)

Description

Assignments within a block of adjacent assignments whose assignment operators are not aligned are reported.

Assignments separated by one or more blank lines are considered to be in distinct blocks.

Configuration

See generic service options.

Rule NC3.3.2.d

Summary

The # in a preprocessor directive shall always be located at the start of a line, though the directives themselves may be indented within a #if or #ifdef sequence. (See page 35 of BARR-C-2018 [8] .)

Description

The initial character # for a pre-processor directives must be in column 1.

Configuration

See generic service options.

Rule NC3.3.3.a

Summary

No line of code shall contain more than one statement. (See page 36 of BARR-C-2018 [8] .)

Description

Each statement that is followed by a ;, apart from comments, must have no other code on the same line.

Configuration

See generic service options.

Option contexts
contexts
-config=NC3.3.3.a,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.3.3.b

Summary

There shall be a blank line before and after each natural block of code. (See page 36 of BARR-C-2018 [8] .)

Description

There must be a blank line immediately before and after each if, while, for, switch statement and before and after each sequence of declarations in a block statement. Blank lines before/after the initial/final statements of a block are not required.

Any macro invocation is treated as a function call and the content of the macro is ignored.

Configuration

See generic service options.

Rule NC3.3.3.c

Summary

Each source file shall terminate with a comment marking the end of file followed by a blank line. (See page 36 of BARR-C-2018 [8] .)

Description

There must be a comment and a blank line at the end of each file.

Configuration

See generic service options.

Rule NC3.3.4.a

Summary

Each indentation level should align at a multiple of 4 characters from the start of the line. (See page 37 of BARR-C-2018 [8] .)

Description

Reports the source lines where the indentation is not a multiple of 4 spaces.

The indent_size service configuration can be used to specify an alternative indentation size.

For example, the following configure line changes the indentation size to be 2 spaces:

-doc="Set indentation size to 2 spaces."
-config=NC3.3.4.a,!indent_size=2

Configuration

See generic service options.

Option indent_size
indent_size
-config=NC3.3.4.a,indent_size=SIZE

Specify size of indentation.

SIZE:

the number of spaces per indentation level. It must be an integer greater than or equal to 0.

Default:

-config=NC3.3.4.a,indent_size=4

Rule NC3.3.4.b

Summary

Within a switch statement, the case labels shall be aligned; the contents of each case block shall be indented once from there. (See page 37 of BARR-C-2018 [8] .)

Description

In a switch statement, the case and default labels must be aligned; statements in the case or default block, apart from break and goto labels, must be indented.

Configuration

See generic service options.

Rule NC3.3.5.a

Summary

The tab character (ASCII 0x09) shall never appear within any source code file. (See page 39 of BARR-C-2018 [8] .)

Description

The <TAB> character must not be used.

Configuration

See generic service options.

Rule NC3.3.6.a

Summary

Whenever possible, all source code lines shall end only with the single character LF (ASCII 0x0A), not with the pair CR-LF (0x0D 0x0A). (See page 40 of BARR-C-2018 [8] .)

Description

The <CR> (with ascii value 13) must not be used.

Configuration

See generic service options.

Rule NC3.3.6.b

Summary

The only other non-printable character permitted in a source code file is the form feed character FF (ASCII 0x0C). (See page 40 of BARR-C-2018 [8] .)

Description

Unprintable characters except for <TAB>, <LF>, <CR> and <FF> (with ascii values 9, 10, 12 and 13) are reported.

Configuration

See generic service options.

Rule NC3.4.1.a

Summary

All module names shall consist entirely of lowercase letters, numbers, and underscores. No spaces shall appear within the file module’s header and source file names. (See page 41 of BARR-C-2018 [8] .)

Description

Names of source and header files that contain characters other than lowercase letters, numbers and underscores are reported.

Configuration

See generic service options.

Rule NC3.4.1.b

Summary

All module names shall be unique in their first 8 characters and end with suffices .h and .c for the header and source file names respectively. (See page 41 of BARR-C-2018 [8] .)

Description

Source files must have the .c extension and the names must be unique in the first 8 characters. Similarly, header files must have the .h extension and the names must be unique in the first 8 characters.

Configuration

See generic service options.

Rule NC3.4.1.c

Summary

No module’s header file name shall share the name of a header file from the C Standard Library or C++ Standard Library. (See page 41 of BARR-C-2018 [8] .)

Description

User header files must not have the same name as a standard library file.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=NC3.4.1.c,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=NC3.4.1.c,reserved_standard="min(c99)", "min(c++98)"

Rule NC3.4.1.d

Summary

Any module containing a main() function shall have the word main as part of its source file name. (See page 41 of BARR-C-2018 [8] .)

Description

It is reported if the main file for a unit includes the main() function but the file name does not include the substring main.

Configuration

See generic service options.

Rule NC3.4.2.a

Summary

There shall always be precisely one header file for each source file and they shall always have the same root name. (See page 53 of BARR-C-2018 [8] .)

Description

It will be reported if there is none or more than one header file that has the same name as the main file.

Configuration

See generic service options.

Rule NC3.4.2.b

Summary

Each header file shall contain a preprocessor guard against multiple inclusion. (See page 42 of BARR-C-2018 [8] .)

Description

Note that this applies to any included file regardless of the file name extension.

Such a file must use one of the mechanisms: ifndef, ifdef and pragma where these are defined by the forms:

  • ifndef

#ifndef Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
#if !defined Guard_Id
#define Guard_Id ...
...
#else /* Optional */
#endif
  • ifdef

#ifdef Guard_Id
#else
#define Guard_Id ...
...
#endif
#if defined Guard_Id
#else
#define Guard_Id ...
...
#endif
  • pragma

#pragma first

It is also shown if the guard’s macro name is used elsewhere in any #define or #undef in the project.

There are no checks on the form or syntax of the macro name.

Configuration

See generic service options.

Option guard
guard
-config=NC3.4.2.b,guard={FILE, {CHECK,...}},...

Specify the allowed mechanisms to prevent the contents of a header file being included twice using advanced features.

The configuration’s content is an ordered list of file selectors with conditions; the conditions in the first clause whose file selector matches the file are checked.

FILE:

a -file_tag identifier or a matcher expression used to select the files.

CHECK

Accepted forms are:

  • mechanism(MECHANISM[||MECHANISM]*): the guard’s mechanism

  • guard(GUARD): the file name replacer REPLACER (see the -replacer global configuration). The input provided to the replacer is the canonical pathname of the guarded file; the macro name must match exactly, or must match the regular expression defined by FMT

  • comment(COMMENT_MATCHER): it will be reported if there is no matching comment following the #endif

  • reuse(REUSE_TAG): tag indicating if what reuse of the macro name should be reported

  • regex(): the replaced name is a regular expression that must match the macro guard name

REUSE_TAG

accepted forms are:

  • all_code: it is reported if the same guard identifier is reused for an identifier anywhere in the project code

  • all_defined: it is reported if the same guard identifier is redefined or undefined anywhere in the project

  • all_guards_in_unit: it is reported if the same guard identifier is used for more than one header file in the translation unit

  • all_guards_in_project: it is reported if the same guard identifier is used for more than one header file in the project

MECHANISM

accepted forms are:

  • any: any mechanism

  • ifndef: the guard mechanism using #ifndef Guard_Id or if !defined Guard_Id

  • ifdef: the mechanism using #if defined Guard_Id

  • pragma: the mechanism #pragma once

Default:

-config=NC3.4.2.b,guard={^.*$,
    {"mechanism(any)",
      "reuse(all_defined)",
      "comment(any())"}}

Option directives
directives
-config=NC3.4.2.b,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule NC3.4.2.c

Summary

The header file shall identify only the procedures, constants, and data types (via prototypes or macros, #define and typedefs, respectively) about which it is strictly necessary for other modules to be informed. (See page 42 of BARR-C-2018 [8] .)

Description

Reports any declaration in a header file except for:

  • inline function definitions;

  • function prototype declarations;

  • typedef declarations;

  • declarations in public API files.

  • tag declarations needed by the translation unit.

Notes:

  • all variable declarations with internal or external linkage are reported;

  • classes, unions and structures are only reported if they are not needed since NC3.5.1.b will check that they are declared via a typedef.

A file can be declared part of a public API using the -file_tag and -public_files global configurations. For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

declarations in files whose name matches the regular expression ^my_public_header.h$ will not be reported.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.4.2.c,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.4.3.b

Summary

Each source file shall be comprised of an ordered subset of a given list of possible sections. (See page 43 of BARR-C-2018 [8] .)

Description

It will be reported if the main file does not order its sections as specified.

Reports if an #include directive is preceded by any code apart from other preprocessor directives or comments.

Global variable definitions are also checked by NC3.7.2.c.

Tag declarations are not checked since it is checked by NC3.5.1.b that they are always embedded in a typedef_decl.

Exceptions

The headers and the exception service configurations allow for some exceptions to the positioning of the #include directive.

Configuration

See generic service options.

Option user_file_select
user_file_select
-config=NC3.4.3.b,user_file_select={TAGS, MATCHER},...

Specifies the report tags for matching files.

The configuration’s content is file tagger.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

matcher for files to be checked (see the -file_tag global configuration).


Option declarations
declarations
-config=NC3.4.3.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.4.3.b,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option headers
headers
-config=NC3.4.3.b,headers={TAGS, HEADER_MATCHER},...

Specifies report tags for the #include directives.

The configuration’s content is a list of clauses specifying report tags for matching #include names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

HEADER_MATCHER:

the #include argument matcher including quotes or chevrons. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option exception
exception
-config=NC3.4.3.b,exception=EXCEPT,...

Specify allowed exceptions to this rule.

{EXCEPT,…}:

allowed exception to this rule. Accepted members are:

  • extern_C: constructs of the form extern "C" {...} are not considered to be code (for ‘C++’ rules);

  • extern_C_only: constructs of the form extern "C" are not considered to be code (for ‘C++’ rules); the following {…} may only contain preprocessor directives;

  • namespace_alias: constructs of the form namespace A = B are not considered to be code;

  • if_directive: directive subsections that are bounded by the #if, #else, #elif and #endif directives are considered as separate code chunks;


Option ignored_comments
ignored_comments
-config=NC3.4.3.b,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.4.3.c

Summary

Each source file shall always #include the header file of the same name. (See page 43 of BARR-C-2018 [8] .)

Description

It will be reported if the main file does not directly include a header file that has the same name.

Configuration

See generic service options.

Rule NC3.4.3.d

Summary

Absolute paths shall not be used in include file names. (See page 43 of BARR-C-2018 [8] .)

Description

Absolute paths must not be used in #include directives.

To allow \ in file path names, the path_uses_backslash service configuration should be used.

The reports can be tagged using the include_name_exception.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=NC3.4.3.d,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=NC3.4.3.d,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule NC3.4.3.f

Summary

No source file shall #include another source file. (See page 43 of BARR-C-2018 [8] .)

Description

Source files must not include any file with extension

To allow \ in file path names, the path_uses_backslash service configuration should be used.

The reports can be tagged using the include_name_exception. .c or .cpp.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=NC3.4.3.f,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=NC3.4.3.f,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule NC3.5.1.a

Summary

The names of all new data types, including structures, unions, and enumerations, shall consist only of lowercase characters and internal underscores and end with _t. (See page 45 of BARR-C-2018 [8] .)

Description

The names of user-defined types must begin with a lowercase letter, include only lowercase characters and underscores and end with _t.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.5.1.a,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.5.1.a,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.5.1.a,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.5.1.a,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.5.1.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.5.1.a,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.5.1.a,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.5.1.b

Summary

All new structures, unions, and enumerations shall be named via a typedef. (See page 45 of BARR-C-2018 [8] .)

Description

Reports structures, unions, and enumerations that are not named via a typedef.

Configuration

See generic service options.

Rule NC3.5.1.c

Summary

The name of all public data types shall be prefixed with their module name and an underscore. (See page 45 of BARR-C-2018 [8] .)

Description

Each typedef should have a name prefixed by the base name of the file in which it is declared.

Configuration

See generic service options.

Rule NC3.5.2.a

Summary

Whenever the width, in bits or bytes, of an integer value matters in the program, one of the fixed width data types shall be used in place of char, short, int, long, or long long. The signed and unsigned fixed width integer types shall be as shown in the given table. (See page 46 of BARR-C-2018 [8] .)

Description

Reports any direct use of signed and unsigned variants of char, int, short, long, long long, float, double or long double and any typedef name for any of these variants that does not indicate the size and signedness.

The typedef name is non-compliant if it does not have one of the following forms (where @BITS@ is replaced by the length in bits):

  • signed integer type - int@BITS@_t,

  • unsigned integer type - uint@BITS@_t,

  • floating type - float@BITS@_t.

The naming service configuration can be used to change the schema.

Configuration

See generic service options.

Option naming
naming
-config=NC3.5.2.a,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=NC3.5.2.a,naming=misra

Option declarations
declarations
-config=NC3.5.2.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=NC3.5.2.a,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule NC3.5.2.b

Summary

The keywords short and long shall not be used. (See page 46 of BARR-C-2018 [8] .)

Description

Reports any use of signed and unsigned variants of short or long.

Configuration

See generic service options.

Option naming
naming
-config=NC3.5.2.b,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=NC3.5.2.b,naming={}

Option declarations
declarations
-config=NC3.5.2.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=NC3.5.2.b,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule NC3.5.2.c

Summary

Use of the keyword char shall be restricted to the declaration of and operations concerning strings. (See page 46 of BARR-C-2018 [8] .)

Description

Reports any use of plain char type for variables in numeric expressions.

Configuration

See generic service options.

Option calls
calls
-config=NC3.5.2.c,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule NC3.5.3.a

Summary

Bit-fields shall not be defined within signed integer types. (See page 47 of BARR-C-2018 [8] .)

Description

Bitfields whose types are signed are reported.

Note that, for this service, the report category is the reported type.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.5.3.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=NC3.5.3.a,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule NC3.5.3.b

Summary

None of the bit-wise operators (i.e., &, |, ~, ^, <<, and >>) shall be used to manipulate signed integer data. (See page 47 of BARR-C-2018 [8] .)

Description

Bitwise operations on signed integers are reported.

Configuration

See generic service options.

Option statements
statements
-config=NC3.5.3.b,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.5.3.b,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.5.3.c

Summary

Signed integers shall not be combined with unsigned integers in comparisons or expressions. In support of this, decimal constants meant to be unsigned should be declared with a u at the end. (See page 47 of BARR-C-2018 [8] .)

Description

It is shown if:

  • the value of an integer expression is assigned, copied or converted to an object with an integer type with different signedness;

  • integer operands of any binary operator in which the usual arithmetic conversions are performed have different signedness;

  • the then and else expressions in conditional operators have integral type with different signedness;

  • an integer constant whose magnitude is such that it is intrinsically unsigned, does not have a U or u suffix.

Note that the types checked and compared are the written types and ignores any implicit integral promotions.

Configuration

See generic service options.

Option contexts
contexts
-config=NC3.5.3.c,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option etypes
etypes
-config=NC3.5.3.c,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Option literals
literals
-config=NC3.5.3.c,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule NC3.5.4.a

Summary

Avoid the use of floating point constants and variables whenever possible. Fixed-point math may be an alternative. (See page 48 of BARR-C-2018 [8] .)

Description

Any use of floating-point literals or variables are reported as cautions.

Configuration

See generic service options.

Option statements
statements
-config=NC3.5.4.a,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.5.4.a,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.5.5.b

Summary

Appropriate care shall be taken to prevent the compiler from altering the intended order of the bits within bit-fields. (See page 49 of BARR-C-2018 [8] .)

Description

Reports declarations of bit-fields.

Imprecision

Cautions are reported for all bit-field declarations.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.5.5.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.5.6.a

Summary

Boolean variables shall be declared as type bool. (See page 51 of BARR-C-2018 [8] .)

Description

Reports if operands of the logical operators && or || or ! or the condition parts of selection or iteration statements are references to variables or members and do not have type bool.

Configuration

See generic service options.

Option etypes
etypes
-config=NC3.5.6.a,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule NC3.5.6.b

Summary

Non-Boolean values shall be converted to Boolean via use of relational operators (e.g., < or !=), not via casts. (See page 51 of BARR-C-2018 [8] .)

Description

Any casts from non-Boolean types to Boolean types are reported.

Configuration

See generic service options.

Option casts
casts
-config=NC3.5.6.b,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule NC3.6.1.a

Summary

No procedure shall have a name that is a keyword of any standard version of the C or C++ programming language. Restricted names include interrupt, inline, class, true, false, public, private, friend, protected, and many others. (See page 52 of BARR-C-2018 [8] .)

Description

No function may be declared with a name that is also a keyword.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=NC3.6.1.a,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=NC3.6.1.a,reserved_standard="max(c11)", c++11

Option declarations
declarations
-config=NC3.6.1.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.6.1.b

Summary

No procedure shall have a name that overlaps a function in the C Standard Library. (See page 52 of BARR-C-2018 [8] .)

Description

No function declaration may use a reserved identifier that is reserved for a function in the standard library.

If the compiler language is C++, then tag qualifiers are considered relevant.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=NC3.6.1.b,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=NC3.6.1.b,reserved_standard="std()"

Option declarations
declarations
-config=NC3.6.1.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.6.1.c

Summary

No procedure shall have a name that begins with an underscore. (See page 52 of BARR-C-2018 [8] .)

Description

Reports if function names begin with the _ character.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.6.1.c,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.6.1.c,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.6.1.c,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.6.1.c,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.6.1.c,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.6.1.c,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.6.1.c,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.6.1.d

Summary

No procedure name shall be longer than 31 characters. (See page 52 of BARR-C-2018 [8] .)

Description

Reports if function names have more than 31 characters.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.6.1.d,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.6.1.d,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.6.1.d,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.6.1.d,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.6.1.d,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.6.1.d,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.6.1.d,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.6.1.e

Summary

No function name shall contain any uppercase letters. (See page 52 of BARR-C-2018 [8] .)

Description

Reports if function names include uppercase letters.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.6.1.e,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.6.1.e,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.6.1.e,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.6.1.e,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.6.1.e,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.6.1.e,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.6.1.e,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.6.1.f

Summary

No macro name shall contain any lowercase letters. (See page 52 of BARR-C-2018 [8] .)

Description

Reports if macro names include lowercase letters.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.6.1.f,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.6.1.f,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.6.1.f,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.6.1.f,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.6.1.f,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.6.1.f,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.6.1.f,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.6.1.g

Summary

Underscores shall be used to separate words in procedure names. (See page 52 of BARR-C-2018 [8] .)

Description

Reports if function or method names use words not separated by ‘_’. Note that to specify the vocabulary for the words, two files must be provided:

  • a context_dictionary service configuration naming an English language dictionary file, and

  • a project_dictionary service configuration naming a dictionary file containing special words, acronyms,and abbreviations allowed in the project.

See vocabulary for more information about the vocabulary dictionaries and their use.

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=NC3.6.1.g,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=NC3.6.1.g,project_dictionary=""

Option context_dictionary
context_dictionary
-config=NC3.6.1.g,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=NC3.6.1.g,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=NC3.6.1.g,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=NC3.6.1.g,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=NC3.6.1.g,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=NC3.6.1.g,segmentation_stops_after=underscore

Option max_no_case_length
max_no_case_length
-config=NC3.6.1.g,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=NC3.6.1.g,max_no_case_length=16

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.6.1.g,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.6.1.g,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.6.1.g,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.6.1.g,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.6.1.g,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.6.1.g,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.6.1.g,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option good_words_file
good_words_file
-config=NC3.6.1.g,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=NC3.6.1.g,good_words_file=""

Option bad_words_file
bad_words_file
-config=NC3.6.1.g,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=NC3.6.1.g,bad_words_file=""

Option good_items_file
good_items_file
-config=NC3.6.1.g,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=NC3.6.1.g,good_items_file=""

Option bad_items_file
bad_items_file
-config=NC3.6.1.g,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=NC3.6.1.g,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=NC3.6.1.g,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=NC3.6.1.g,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=NC3.6.1.g,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=NC3.6.1.g,bad_item_regexs={}

Rule NC3.6.1.i

Summary

The names of all public functions shall be prefixed with their module name and an underscore. (See page 52 of BARR-C-2018 [8] .)

Description

Each function with program visibility should have a name prefixed by the base name of the file in which it is declared.

Configuration

See generic service options.

Rule NC3.6.2.a

Summary

All reasonable effort shall be taken to keep the length of each function limited to one printed page, or a maximum of a 100 lines. (See page 54 of BARR-C-2018 [8] .)

Description

Reports any function definition that takes more than 100 lines.

The metric_show service configuration can be used to change the page limit.

Configuration

See generic service options.

Option metric_default_fmt
metric_default_fmt
-config=NC3.6.2.a,metric_default_fmt=FMT

Specify the default format.

FMT:

the default format (see the -fmt global configuration content, template reprtmtc__id_default_fmt) that should be used if no other format is specified; it has fields:

subject_kind

subject kind;

subject_msg

subject message;

subject_name

subject name;

subject_named

Boolean indicating if the subject has a name;

metric_id

metric identifier;

metric_summary

metric summary;

lower_case_metric_summary

metric summary in lowercase;

context_kind

context kind;

context_name

context name;

context_desc

context description;

report_where

a tag with values incremental or final indicating where the metric is reported;

domain

the environment or entity where the metric is reported;

domain_msg

a message describing the environment or entity where the metric is reported;

limit

the metric limit;

rel

the relation used to compare the limit with the metric value;

good_limit

the metric limit that must not be exceeded;

subject_eq_context

Boolean indicating if the context and subject are the same;

value

the actual value for the metric.

Default:

-config=NC3.6.2.a,metric_default_fmt="%{__metric_value_gt_limit_fmt()}"

Option metric_show
metric_show
-config=NC3.6.2.a,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=NC3.6.2.a,metric_show={B.LINES_FUNC, 100}

Option declarations
declarations
-config=NC3.6.2.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.6.2.b

Summary

Whenever possible, all functions shall be made to start at the top of a printed page, except when several small functions can fit onto a single page. (See page 54 of BARR-C-2018 [8] .)

Description

Reports any function whose first character is not at the start of a printed page (ignoring any comments) and spans more than one page.

Configuration

See generic service options.

Rule NC3.6.2.c

Summary

It is a preferred practice that all functions shall have just one exit point and it shall be via a return at the bottom of the function. (See page 54 of BARR-C-2018 [8] .)

Description

It is reported if a function does not have a single point of exit at the end of the function block. Notes:

  • what constitutes a function exit node can be specified by means of the exit_kind service configuration;

  • what constitutes an end position of a function can be specified by mean of the end_position service configuration.

For example, with the configure lines:

-doc_begin="Return statements and calls to noreturn functions may only occur at the end
or at the end of a try block or catch handler."
-config=NC3.6.2.c,!exit_kind={return, only_at_end_position, true},
{noreturn_call, only_at_end_position, true}
-config=NC3.6.2.c,end_position+={{compound_try, compound_catch}, true}
-doc_end

the return statements and calls to functions with the noreturn property are considered to be function exits and these exits may only occur at the end of the function body or at the end of a try block or catch handler when last statement of the function body is the handled try block.

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=NC3.6.2.c,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=NC3.6.2.c,exit_kind={return, only_at_end_position, true},
  {noreturn_call, anywhere, true}

Option end_position
end_position
-config=NC3.6.2.c,end_position={{POS,...}, END},...

Specify the end positions and if an exit node is required.

The configuration’s content is a list of the end positions and if a exit kind node is required at that position.

{POS,…}:

end position in the function body. Accepted members are:

  • compound: the end of the body when the body is a compound statement;

  • try: the end of the body when the body is a try block;

  • catch: the end of a catch handler when the body is a try block;

  • compound_try: the end of a try block when last statement of the function body is the try block;

  • compound_catch: the end of a catch handler when last statement of the function body is the handled try block;

END:

whether the exit position must always have an exit kind node. Accepted values are:

  • true: the exit position must always have an exit node;

  • false: the exit position does not have to have an exit node;

Default:

-config=NC3.6.2.c,end_position={{compound, try}, false}

Rule NC3.6.2.d

Summary

A prototype shall be declared for each public function in the module header file. (See page 54 of BARR-C-2018 [8] .)

Description

A function with external linkage must have a prototype declaration in a header file.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.6.2.d,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.6.2.e

Summary

All private functions shall be declared static. (See page 54 of BARR-C-2018 [8] .)

Description

Any object or function declaration or definition with internal linkage must include the storage class specifier static.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.6.2.e,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.6.2.f

Summary

Each parameter shall be explicitly declared and meaningfully named. (See page 54 of BARR-C-2018 [8] .)

Description

Each parameter declaration in a function prototype declaration must have an identifier. This applies to all prototypes:

  • a function prototype declaration,

  • a declaration of a function pointer,

  • any type-casts to function pointer types.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.6.2.f,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.6.3.a

Summary

Parameterized macros shall not be used if an inline function can be written to accomplish the same behavior. (See page 56 of BARR-C-2018 [8] .)

Description

A function-like macro in the non-skipped compiled sources is considered replaceable by a function call if none of the following hold:

  • one of the macro invocation’s arguments is not expanded to an expression or it is expanded to an expression that cannot be interpreted as an rvalue (and hence cannot be used as a function call argument);

  • the macro body’s text contains special tokens (e.g. __LINE__, __FILE__, __COUNTER_, #, ##);

  • the macro is in a context that is not supported by the standard for including function calls;

  • the macro expands a non-replaceable macro;

  • the macro is used to emulate a template in C;

  • it is a system macro.

Imprecision

False positives are reported when criteria have not been precisely determined.

Criteria such as the trade-off between code size and execution speed are not considered.

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=NC3.6.3.a,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=NC3.6.3.a,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=NC3.6.3.a,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule NC3.7.1.a

Summary

No variable shall have a name that is a keyword of C, C++, or any other well-known extension of the C programming language, including specifically K&R C and C99. Restricted names include interrupt, inline, restrict, class, true, false, public, private, friend, and protected. (See page 60 of BARR-C-2018 [8] .)

Description

No variable or parameter declaration may use a keyword for its identifier.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=NC3.7.1.a,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=NC3.7.1.a,reserved_standard="max(c11)", c++11

Option declarations
declarations
-config=NC3.7.1.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.7.1.b

Summary

No variable shall have a name that overlaps with a variable name from the C Standard Library. (See page 60 of BARR-C-2018 [8] .)

Description

No variable or parameter may use a reserved identifier that is reserved for a variable in the standard library.

Configuration

See generic service options.

Option reserved_standard
reserved_standard
-config=NC3.7.1.b,reserved_standard=DOM,...

Specify the reserve domains.

The configuration’s content is a set of reserved name domains.

DOM:

domain expression. Accepted forms are:

  • min(STD): the oldest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • max(STD): the newest standard between the STD and the unit standard if the languages are the same, otherwise, it is STD

  • std(): the unit standard

  • STD: the named standard

STD

accepted forms are:

  • c90: the C90 standard [34]

  • c95: the C95 standard [35]

  • c99: the C99 standard [37]

  • c11: the C11 standard [40]

  • c18: the C18 standard [43]

  • c++98: the C++98 standard [36]

  • c++03: the C++03 standard [38]

  • c++11: the C++11 standard [39]

  • c++14: the C++14 standard [41]

  • c++17: the C++17 standard [42]

  • c++20: the C++20 standard [44]

Default:

-config=NC3.7.1.b,reserved_standard="std()"

Option declarations
declarations
-config=NC3.7.1.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.7.1.c

Summary

No variable shall have a name that begins with an underscore. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if variable names begin with the _ character.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.c,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.c,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.c,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.c,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.c,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.c,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.c,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.d

Summary

No variable name shall be longer than 31 characters. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if variable names have more than 31 characters.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.d,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.d,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.d,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.d,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.d,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.d,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.d,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.e

Summary

No variable name shall be shorter than 3 characters, including loop counters. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if variable names have less than 3 characters.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.e,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.e,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.e,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.e,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.e,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.e,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.e,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.f

Summary

No variable name shall contain any uppercase letters. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if variable names include uppercase letters.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.f,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.f,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.f,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.f,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.f,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.f,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.f,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.g

Summary

No variable name shall contain any numeric value that is called out elsewhere, such as the number of elements in an array or the number of bits in the underlying type. (See page 60 of BARR-C-2018 [8] .)

Description

It is reported if a variable name includes a numeric value:

  • and the type of the variable is integral or is a pointer or array (at any depth) to an integral type and the number of bits in the type matches the value, or

  • the type of the variable is an array and the size (of any dimension) matches the value.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.g,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.g,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.g,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.g,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.g,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=NC3.7.1.g,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.h

Summary

Underscores shall be used to separate words in variable names. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if entity variable names use words not separated by _.

Any number in the name that is preceded by _ and either terminates the name or is followed by _ is ignored.

Note that the name must be 3 or more characters; names with one or two characters are reported using Rule 7.1.e. Note that to specify the vocabulary for the words, two files must be provided:

  • a context_dictionary service configuration naming an English language dictionary file, and

  • a project_dictionary service configuration naming a dictionary file containing special words, acronyms,and abbreviations allowed in the project.

See vocabulary for more information about the vocabulary dictionaries and their use.

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=NC3.7.1.h,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=NC3.7.1.h,project_dictionary=""

Option context_dictionary
context_dictionary
-config=NC3.7.1.h,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=NC3.7.1.h,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=NC3.7.1.h,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=NC3.7.1.h,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=NC3.7.1.h,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=NC3.7.1.h,segmentation_stops_after=underscore

Option max_no_case_length
max_no_case_length
-config=NC3.7.1.h,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=NC3.7.1.h,max_no_case_length=16

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.h,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.h,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.h,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.h,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.h,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.h,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.h,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option good_words_file
good_words_file
-config=NC3.7.1.h,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=NC3.7.1.h,good_words_file=""

Option bad_words_file
bad_words_file
-config=NC3.7.1.h,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=NC3.7.1.h,bad_words_file=""

Option good_items_file
good_items_file
-config=NC3.7.1.h,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=NC3.7.1.h,good_items_file=""

Option bad_items_file
bad_items_file
-config=NC3.7.1.h,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=NC3.7.1.h,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=NC3.7.1.h,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=NC3.7.1.h,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=NC3.7.1.h,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=NC3.7.1.h,bad_item_regexs={}

Rule NC3.7.1.j

Summary

The names of any global variables shall begin with the letter g. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if global variable names do not have a prefix that includes the character g.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.j,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.j,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.j,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.j,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.j,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.j,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.j,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.k

Summary

The names of any pointer variables shall begin with the letter p. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if variables with pointer to non-pointer types do not have a prefix that includes the character p.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.k,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.k,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.k,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.k,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.k,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.k,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.k,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.l

Summary

The names of any pointer-to-pointer variables shall begin with the letters pp. (See page 60 of BARR-C-2018 [8] .)

Description

Reports if variables with pointer to pointer types do not have a prefix that includes the string pp.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.l,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.l,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.l,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.l,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.l,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.l,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.l,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.n

Summary

The names of any variables representing non-pointer handles for objects, e.g., file handles, shall begin with the letter h. (See page 61 of BARR-C-2018 [8] .)

Description

Reports if variables representing file handles do not have a prefix that includes the character h.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.n,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.n,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.n,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.n,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.n,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.n,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.n,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.1.o

Summary

In the case of a variable name requiring multiple of the above prefixes, the order of their inclusion before the first underscore shall be [g][p|pp][b|h]. (See page 61 of BARR-C-2018 [8] .)

Description

Reports if variable names have prefix characters gpbh in the wrong order.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=NC3.7.1.o,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=NC3.7.1.o,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=NC3.7.1.o,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=NC3.7.1.o,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=NC3.7.1.o,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.1.o,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=NC3.7.1.o,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.2.a

Summary

All variables shall be initialized before use. (See page 62 of BARR-C-2018 [8] .)

Description

Notes:

  • An automatic variable does not need to be initialized at the declaration, but a value must be written to it before it is used.

  • Initializing any one member of a union is not considered as (proper) initialization of the other members.

  • To specify the read and write properties for the called functions use the -call_properties global configuration with properties pointee_read and pointee_write for the read and write properties of non-const parameters and const_pointee_read and const_pointee_write for the read and write properties of const parameters.

For example, with the configuration line:

-call_properties+={"decl(name(gettimeofday))",
{"pointee_read(1..=never)",
"pointee_write(1..=always)"}}

the first argument in a call to the function gettimeofday is not reported for not being initialized and, after the call, it is assumed that the first argument has been initialized.

Implementation

Reports if an automatic variable may be used without initialization.

Imprecision

Cautions are reported when the checker cannot determine the necessary execution order or whether all the components of a data structure have been initialized.

  • Cautions may be caused by bad style coding such as in the following example:

int f() {
  int a;
  int b = 1;
  if (b) a = 3;
  return a;
}
  • In the presence of backward or sideways jumps, the results are unreliable.

int p(int y) {
  int x;
  int i = 0;
loop:
  if (i < y) {
    if (i > 0) {
      return x;
    }
    x = 4;
    ++i;
    goto loop;
  }
  return 0;
}

There may be false positives when there are backward goto jumps or when the goto jumps break the control structures.

Configuration

See generic service options.

Option member_areas
member_areas
-config=NC3.7.2.a,member_areas=MAX

Specify the maximum number of uninitialized members to be shown as evidence when reporting a (possibly) uninitialized struct or a class.

MAX:

maximum number of areas in a report showing uninstantiated class or struct members. It must be an integer greater than or equal to 0.


Option declarations
declarations
-config=NC3.7.2.a,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=NC3.7.2.a,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.7.2.b

Summary

It is preferable to define variables as you need them, rather than all at the top of a function. (See page 62 of BARR-C-2018 [8] .)

Description

Reports any variable for which one of the following holds:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • it is used in a single file but declared in a different file.

  • it is not a constant or volatile.

Notes:

  • it is not reported if the variable’s declaration could be moved to the initialization of a for statement;

  • if the variable has a non-constant initialization, the report will be a caution.

Imprecision

Cautions are reported when the variable has a non-constant initialization.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.7.2.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=NC3.7.2.b,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule NC3.7.2.c

Summary

If project- or file-global variables are used, their definitions shall be grouped together and placed at the top of a source code file. (See page 62 of BARR-C-2018 [8] .)

Description

It will be reported if the main file does not have the global variable definitions at the top (apart from #include directives, typedef declarations and macros) of the file.

Configuration

See generic service options.

Option user_file_select
user_file_select
-config=NC3.7.2.c,user_file_select={TAGS, MATCHER},...

Specifies the report tags for matching files.

The configuration’s content is file tagger.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

matcher for files to be checked (see the -file_tag global configuration).


Option declarations
declarations
-config=NC3.7.2.c,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.7.2.c,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule NC3.7.2.d

Summary

Any pointer variable lacking an initial address shall be initialized to NULL. (See page 62 of BARR-C-2018 [8] .)

Description

Pointer variables that are declared without an initializer are reported.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.7.2.d,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.8.1.a

Summary

The comma operator (,) operator shall not be used within variable declarations. (See page 63 of BARR-C-2018 [8] .)

Description

Each variable declarator must be on a separate line and in a separate declaration.

Configuration

See generic service options.

Rule NC3.8.2.a

Summary

It is a preferred practice that the shortest (measured in lines of code) of the if and else if clauses should be placed first. (See page 64 of BARR-C-2018 [8] .)

Description

The size (measured using the configured algorithm) of the if clause must be less than the size of any else if clauses.

Configuration

See generic service options.

Option code_lines_algorithm
code_lines_algorithm
-config=NC3.8.2.a,code_lines_algorithm=ALG
ALG:

the algorithm used for the complexity value. Accepted forms are:

  • B.SEMI_BLOCK: number of statements and expressions that end with a semicolon

Default:

-config=NC3.8.2.a,code_lines_algorithm=B.SEMI_BLOCK

Rule NC3.8.2.b

Summary

Nested if...-else statements shall not be deeper than two levels. Use function calls or switch statements to reduce complexity and aid understanding. (See page 64 of BARR-C-2018 [8] .)

Description

Any if statement nested to a depth greater than 2 is reported.

Note that the metrics can be changed using the metric_show service configuration with the metric B.IFNEST_PIF.

Configuration

See generic service options.

Option metric_show
metric_show
-config=NC3.8.2.b,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=NC3.8.2.b,metric_show={B.IFNEST_PIF, "=3"}

Option declarations
declarations
-config=NC3.8.2.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.8.2.c

Summary

Assignments shall not be made within an if or else if test. (See page 64 of BARR-C-2018 [8] .)

Description

Assignments in the conditional expressions in an iteration or selection statement are reported

Configuration

See generic service options.

Option statements
statements
-config=NC3.8.2.c,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.8.2.c,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.8.2.d

Summary

Any if statement with an else if clause shall end with an else clause. (See page 64 of BARR-C-2018 [8] .)

Description

Reports any if statement if the final else if:

  • has no else clause and no matching comment as to why it is missing,

  • has an else clause that is the null statement and no matching comment as to why it is null, or

  • has an else clause that is a compound statement that has no effect and there is no matching explanatory comment.

The default configuration does not check the content or style of the comment; however the else_empty service configuration can be used to provide a comment matcher.

Configuration

See generic service options.

Option else_empty
else_empty
-config=NC3.8.2.d,else_empty={EMPTY_ELSE, COMMENT_MATCHER},...

Specify what is meant by an empty else clause and whether a comment can be used instead.

The configuration’s content is a set of pairs indicating the intended meaning for empty else and an optional matcher for a replacement comment.

EMPTY_ELSE:

choose what is meant by empty else. Accepted values are:

  • null: the else clause contains just a null statement and any comment must be immediately after the null statement;

  • empty_compound: the else clause contains just an empty block statement and any comment must be in the block or immediately after the block statement;

  • no_effect: the else clause contains a block statement with code that has no effect and any comment must be in the block or immediately after the block statement;

  • missing: there is no else clause and any comment must be immediately after the else if statement;

COMMENT_MATCHER:

no comment, indicating that comments are ignored or a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=NC3.8.2.d,else_empty={missing, "none()"}, {no_effect, "any()"}

Option ignored_comments
ignored_comments
-config=NC3.8.2.d,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.8.3.a

Summary

The break for each case shall be indented to align with the associated case, rather than with the contents of the case code block. (See page 65 of BARR-C-2018 [8] .)

Description

In a switch statement, each break statement must be aligned with the preceding case or default clause.

Configuration

See generic service options.

Rule NC3.8.3.b

Summary

All switch statements shall contain a default block. (See page 65 of BARR-C-2018 [8] .)

Description

Reports any switch statement that does not have a default label

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.8.3.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule NC3.8.3.c

Summary

Any case designed to fall through to the next shall be commented to clearly explain the absence of the corresponding break. (See page 65 of BARR-C-2018 [8] .)

Description

A case or default clause must end with a break or throw statement or a matching comment.

A comment may be used in place of the break or throw statement. To specify the allowed form of the comment use the replacement_comment service configuration.

For example, with the configuration line:

-doc="Only Fall through to next statement comments are accepted in place of the default clause."
-config=NC3.8.3.c,
  +replacement_comment={missing_terminal,
    "^.*([fF]all[- ]?[tT]hr(ough|u)|FALL[- ]?THR(OUGH|U))(s?).*$"}

this service will accept comments such as

Fall through to case: 2

but not other comments such as

do nothing

as acceptible alternatives to a break statement.

Configuration

See generic service options.

Option replacement_comment
replacement_comment
-config=NC3.8.3.c,replacement_comment={WHEN, COMMENT_MATCHER},...

Specify matchers for replacement comments.

The configuration’s content is a list of pairs indicating when a comment is needed and a comment matcher.

WHEN:

when to check a comment replacement. Accepted values are:

  • empty_default: switch default clause is empty;

  • missing_terminal: case or default clause has no terminal statement;

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=NC3.8.3.c,replacement_comment={missing_terminal, "any()"}

Option terminals
terminals
-config=NC3.8.3.c,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=NC3.8.3.c,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=NC3.8.3.c,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.8.4.a

Summary

Magic numbers shall not be used as the initial value or in the endpoint test of a while, do...while, or for loop. (See page 66 of BARR-C-2018 [8] .)

Description

Literal values in the initial part of a for statement or the condition part of any iteration statements are shown.

Allows as exceptions the direct use of values 0, 1 and -1.

Configuration

See generic service options.

Option literals
literals
-config=NC3.8.4.a,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule NC3.8.4.b

Summary

With the exception of the initialization of a loop counter in the first clause of a for statement and the change to the same variable in the third, no assignment shall be made in any loop’s controlling expression. (See page 66 of BARR-C-2018 [8] .)

Description

Assignments in the controlling expression of a do, for or while statement are reported unless they initialize the loop counter in the initialization part of a for statement or change the loop counter in the third part.

In a for statement, a variable is assumed to be a loop counter if it is modified in the third part or in the body and tested in the second part.

Configuration

See generic service options.

Rule NC3.8.4.c

Summary

Infinite loops shall be implemented via the controlling expression for (;;). (See page 66 of BARR-C-2018 [8] .)

Description

Any goto statements that jump to a previous label statement are reported.

Infinite loops idioms using while or do statements are reported.

Configuration

See generic service options.

Rule NC3.8.4.d

Summary

Each loop with an empty body shall feature a set of braces enclosing a comment to explain why nothing needs to be done until after the loop terminates. (See page 66 of BARR-C-2018 [8] .)

Description

Reports an empty iteration statement that does not have an explanatory comment.

The stmt_document_selector service configuration can suppress the expressions checked and, for those not suppressed, specify the comment’s expected position relative to an associated statement.

The selection of explanatory comments depends on a comment matcher (see the -comment_selector global configuration):

  • All the single comments immediately before the targeted expression and not separated by a blank line are assumed to contribute to the full documentation for the expression. Hence, before the comments are checked the initial and terminating comment markers //, /* and */ are removed and the resulting texts are merged.

  • the stmt_doc_matcher service configuration specifies a comment matcher that should match the merged comment text. The default selector document_any_comments will match any merged comment.

Configuration

See generic service options.

Option statements
statements
-config=NC3.8.4.d,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.8.4.d,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option stmt_doc_matcher
stmt_doc_matcher
-config=NC3.8.4.d,stmt_doc_matcher=CMNT_MATCHER

Specify the metric with a comment matcher.

CMNT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=NC3.8.4.d,stmt_doc_matcher=__document_any_comments

Option stmt_document_selector
stmt_document_selector
-config=NC3.8.4.d,stmt_document_selector={TAGS, CTXT, STMT, WHERE},...

Specifies the report tags for undocumented statements.

The configuration’s content is list of tagged statement and context matchers with a flag to indicate where the documentation is placed relative to the statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

STMT:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.

WHERE:

where documentation is placed. Accepted values are:

  • above_node: above the node;

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;


Option ignored_comments
ignored_comments
-config=NC3.8.4.d,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule NC3.8.5.a

Summary

The use of goto statements shall be restricted as per Rule 1.7.c. (See page 67 of BARR-C-2018 [8] .)

Description

Reports any goto statement (indirect or direct).

Configuration

See generic service options.

Option statements
statements
-config=NC3.8.5.a,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.8.5.a,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule NC3.8.5.b

Summary

C Standard Library functions abort(), exit(), setjmp(), and longjmp() shall not be used. (See page 67 of BARR-C-2018 [8] .)

Description

Reports any use of:

  • the standard library functions abort, exit, getenv and system provided by stdlib.h;

  • the standard library header setjmp.h and any use of functions, types or macros provided by setjmp.h.

Configuration

See generic service options.

Option declarations
declarations
-config=NC3.8.5.b,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=NC3.8.5.b,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule NC3.8.6.a

Summary

When evaluating the equality of a variable against a constant, the constant shall always be placed to the left of the equal-to operator ( == ). (See page 68 of BARR-C-2018 [8] .)

Description

Reports when constants are not on the left of the equality == operator.

Configuration

See generic service options.

Option statements
statements
-config=NC3.8.6.a,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=NC3.8.6.a,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


BARR-C:2018 Coding Standard Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the BARR-C:2018 coding standard [8].

For all rules, the mapping between the rules and the ECLAIR service identifiers is one-to-one and straightforward. e.g., BARR-C:2018 Rule 3.2.a maps to ECLAIR service NC3.3.2.a.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

NC3 synopsis: supported BARR-C:2018 rules

Id

Headline

Precision

NC3.1.1.a

All programs shall be written to comply with the C99 version of the ISO C Programming Language Standard

Complete

NC3.1.1.d

Preprocessor directive #define shall not be used to alter or rename any keyword or other aspect of the programming language

Exact

NC3.1.2.a

The width of all lines in a program shall be limited to a maximum of 80 characters

Exact

NC3.1.3.a

Braces shall always surround the blocks of code (a.k.a., compound statements), following if, else, switch, while, do, and for statements; single statements and empty statements following these keywords shall also always be surrounded by braces

Exact

NC3.1.3.b

Each left brace ({) shall appear by itself on the line below the start of the block it opens. The corresponding right brace (}) shall appear by itself in the same position the appropriate number of lines later in the file

Exact

NC3.1.4.a

Do not rely on C’s operator precedence rules, as they may not be obvious to those who maintain the code. To aid clarity, use parentheses (and/or break long statements into multiple lines of code) to ensure proper execution order within a sequence of operations

Exact

NC3.1.4.b

Unless it is a single identifier or constant, each operand of the logical AND (&&) and logical OR (||) operators shall be surrounded by parentheses

Exact

NC3.1.5.a

Abbreviations and acronyms should generally be avoided unless their meanings are widely and consistently understood in the engineering community

Exact

NC3.1.5.b

A table of project-specific abbreviations and acronyms shall be maintained in a version-controlled document

Process

NC3.1.6.a

Each cast shall feature an associated comment describing how the code ensures proper behavior across the range of possible values on the right side

Process

NC3.1.7.a

The auto keyword shall not be used

Exact

NC3.1.7.b

The register keyword shall not be used

Exact

NC3.1.7.c

It is a preferred practice to avoid all use of the goto keyword. If goto is used it shall only jump to a label declared later in the same or an enclosing block

Exact

NC3.1.7.d

It is a preferred practice to avoid all use of the continue keyword

Exact

NC3.1.8.a

The static keyword shall be used to declare all functions and variables that do not need to be visible outside of the module in which they are declared

Exact

NC3.1.8.b

The const keyword shall be used whenever appropriate

Best-effort

NC3.2.1.a

Single-line comments in the C++ style (i.e., preceded by //) are a useful and acceptable alternative to traditional C style comments (i.e., /* ... */)

Safe

NC3.2.1.b

Comments shall never contain the preprocessor tokens /*, //, or \

Exact

NC3.2.1.c

Code shall never be commented out, even temporarily

Heuristic

NC3.2.2.a

All comments shall be written in clear and complete sentences, with proper spelling and grammar and appropriate punctuation

Exact

NC3.2.2.b

The most useful comments generally precede a block of code that performs one step of a larger algorithm

Process

NC3.2.2.d

The number and length of individual comment blocks shall be proportional to the complexity of the code they describe

Exact

NC3.2.2.h

Each module and function shall be commented in a manner suitable for automatic documentation generation, e.g., via Doxygen

Exact

NC3.3.1.a

Each of the keywords if, else, while, for, switch, and return shall always be followed by one space when there is additional program text on the same line

Exact

NC3.3.1.b

Each of the assignment operators =, +=, -=, *=, /=, %=, &=, |=, ^=, ~=, and != shall always be preceded and followed by one space

Exact

NC3.3.1.c

Each of the binary operators +, -, *, /, %, <, <=, >, >=, ==, !=, <<, >>, &, |, ^, && and || shall always be preceded and followed by one space

Exact

NC3.3.1.d

Each of the unary operators +, -, ++, --, ! and ~, shall be written without a space on the operand side

Exact

NC3.3.1.e

The pointer operators * and & shall be written with white space on each side within declarations but otherwise without a space on the operand side

Exact

NC3.3.1.f

The ? and : characters that comprise the ternary operator shall each always be preceded and followed by one space

Exact

NC3.3.1.g

The structure pointer and structure member operators (-> and ., respectively) shall always be without surrounding spaces

Exact

NC3.3.1.h

The left and right brackets of the array subscript operator ([ and ]) shall be without surrounding spaces, except as required by another white space rule

Exact

NC3.3.1.i

Expressions within parentheses shall always have no spaces adjacent to the left and right parenthesis characters

Exact

NC3.3.1.j

The left and right parentheses of the function call operator shall always be without surrounding spaces, except that the function declaration shall feature one space between the function name and the left parenthesis to allow that one particular mention of the function name to be easily located

Exact

NC3.3.1.k

Except when at the end of a line, each comma separating function parameters shall always be followed by one space

Exact

NC3.3.1.l

Each semicolon separating the elements of a for statement shall always be followed by one space

Exact

NC3.3.1.m

Each semicolon shall follow the statement it terminates without a preceding space

Exact

NC3.3.2.a

The names of variables within a series of declarations shall have their first characters aligned

Exact

NC3.3.2.b

The names of struct and union members shall have their first characters aligned

Exact

NC3.3.2.c

The assignment operators within a block of adjacent assignment statements shall be aligned

Exact

NC3.3.2.d

The # in a preprocessor directive shall always be located at the start of a line, though the directives themselves may be indented within a #if or #ifdef sequence

Exact

NC3.3.3.a

No line of code shall contain more than one statement

Exact

NC3.3.3.b

There shall be a blank line before and after each natural block of code

Exact

NC3.3.3.c

Each source file shall terminate with a comment marking the end of file followed by a blank line

Exact

NC3.3.4.a

Each indentation level should align at a multiple of 4 characters from the start of the line

Exact

NC3.3.4.b

Within a switch statement, the case labels shall be aligned; the contents of each case block shall be indented once from there

Exact

NC3.3.5.a

The tab character (ASCII 0x09) shall never appear within any source code file

Exact

NC3.3.6.a

Whenever possible, all source code lines shall end only with the single character LF (ASCII 0x0A), not with the pair CR-LF (0x0D 0x0A)

Exact

NC3.3.6.b

The only other non-printable character permitted in a source code file is the form feed character FF (ASCII 0x0C)

Exact

NC3.4.1.a

All module names shall consist entirely of lowercase letters, numbers, and underscores. No spaces shall appear within the file module’s header and source file names

Exact

NC3.4.1.b

All module names shall be unique in their first 8 characters and end with suffices .h and .c for the header and source file names respectively

Exact

NC3.4.1.c

No module’s header file name shall share the name of a header file from the C Standard Library or C++ Standard Library

Exact

NC3.4.1.d

Any module containing a main() function shall have the word main as part of its source file name

Exact

NC3.4.2.a

There shall always be precisely one header file for each source file and they shall always have the same root name

Exact

NC3.4.2.b

Each header file shall contain a preprocessor guard against multiple inclusion

Exact

NC3.4.2.c

The header file shall identify only the procedures, constants, and data types (via prototypes or macros, #define and typedefs, respectively) about which it is strictly necessary for other modules to be informed

Exact

NC3.4.3.b

Each source file shall be comprised of an ordered subset of a given list of possible sections

Exact

NC3.4.3.c

Each source file shall always #include the header file of the same name

Exact

NC3.4.3.d

Absolute paths shall not be used in include file names

Exact

NC3.4.3.f

No source file shall #include another source file

Exact

NC3.5.1.a

The names of all new data types, including structures, unions, and enumerations, shall consist only of lowercase characters and internal underscores and end with _t

Exact

NC3.5.1.b

All new structures, unions, and enumerations shall be named via a typedef

Exact

NC3.5.1.c

The name of all public data types shall be prefixed with their module name and an underscore

Exact

NC3.5.2.a

Whenever the width, in bits or bytes, of an integer value matters in the program, one of the fixed width data types shall be used in place of char, short, int, long, or long long. The signed and unsigned fixed width integer types shall be as shown in the given table

Exact

NC3.5.2.b

The keywords short and long shall not be used

Exact

NC3.5.2.c

Use of the keyword char shall be restricted to the declaration of and operations concerning strings

Exact

NC3.5.3.a

Bit-fields shall not be defined within signed integer types

Exact

NC3.5.3.b

None of the bit-wise operators (i.e., &, |, ~, ^, <<, and >>) shall be used to manipulate signed integer data

Exact

NC3.5.3.c

Signed integers shall not be combined with unsigned integers in comparisons or expressions. In support of this, decimal constants meant to be unsigned should be declared with a u at the end

Exact

NC3.5.4.a

Avoid the use of floating point constants and variables whenever possible. Fixed-point math may be an alternative

Exact

NC3.5.5.b

Appropriate care shall be taken to prevent the compiler from altering the intended order of the bits within bit-fields

Complete

NC3.5.6.a

Boolean variables shall be declared as type bool

Exact

NC3.5.6.b

Non-Boolean values shall be converted to Boolean via use of relational operators (e.g., < or !=), not via casts

Exact

NC3.6.1.a

No procedure shall have a name that is a keyword of any standard version of the C or C++ programming language. Restricted names include interrupt, inline, class, true, false, public, private, friend, protected, and many others

Exact

NC3.6.1.b

No procedure shall have a name that overlaps a function in the C Standard Library

Exact

NC3.6.1.c

No procedure shall have a name that begins with an underscore

Exact

NC3.6.1.d

No procedure name shall be longer than 31 characters

Exact

NC3.6.1.e

No function name shall contain any uppercase letters

Exact

NC3.6.1.f

No macro name shall contain any lowercase letters

Exact

NC3.6.1.g

Underscores shall be used to separate words in procedure names

Exact

NC3.6.1.i

The names of all public functions shall be prefixed with their module name and an underscore

Exact

NC3.6.2.a

All reasonable effort shall be taken to keep the length of each function limited to one printed page, or a maximum of a 100 lines

Exact

NC3.6.2.b

Whenever possible, all functions shall be made to start at the top of a printed page, except when several small functions can fit onto a single page

Exact

NC3.6.2.c

It is a preferred practice that all functions shall have just one exit point and it shall be via a return at the bottom of the function

Exact

NC3.6.2.d

A prototype shall be declared for each public function in the module header file

Exact

NC3.6.2.e

All private functions shall be declared static

Exact

NC3.6.2.f

Each parameter shall be explicitly declared and meaningfully named

Exact

NC3.6.3.a

Parameterized macros shall not be used if an inline function can be written to accomplish the same behavior

Complete

NC3.7.1.a

No variable shall have a name that is a keyword of C, C++, or any other well-known extension of the C programming language, including specifically K&R C and C99. Restricted names include interrupt, inline, restrict, class, true, false, public, private, friend, and protected

Exact

NC3.7.1.b

No variable shall have a name that overlaps with a variable name from the C Standard Library

Exact

NC3.7.1.c

No variable shall have a name that begins with an underscore

Exact

NC3.7.1.d

No variable name shall be longer than 31 characters

Exact

NC3.7.1.e

No variable name shall be shorter than 3 characters, including loop counters

Exact

NC3.7.1.f

No variable name shall contain any uppercase letters

Exact

NC3.7.1.g

No variable name shall contain any numeric value that is called out elsewhere, such as the number of elements in an array or the number of bits in the underlying type

Exact

NC3.7.1.h

Underscores shall be used to separate words in variable names

Exact

NC3.7.1.j

The names of any global variables shall begin with the letter g

Exact

NC3.7.1.k

The names of any pointer variables shall begin with the letter p

Exact

NC3.7.1.l

The names of any pointer-to-pointer variables shall begin with the letters pp

Exact

NC3.7.1.n

The names of any variables representing non-pointer handles for objects, e.g., file handles, shall begin with the letter h

Exact

NC3.7.1.o

In the case of a variable name requiring multiple of the above prefixes, the order of their inclusion before the first underscore shall be [g][p|pp][b|h]

Exact

NC3.7.2.a

All variables shall be initialized before use

Safe

NC3.7.2.b

It is preferable to define variables as you need them, rather than all at the top of a function

Complete

NC3.7.2.c

If project- or file-global variables are used, their definitions shall be grouped together and placed at the top of a source code file

Exact

NC3.7.2.d

Any pointer variable lacking an initial address shall be initialized to NULL

Exact

NC3.8.1.a

The comma operator (,) operator shall not be used within variable declarations

Exact

NC3.8.2.a

It is a preferred practice that the shortest (measured in lines of code) of the if and else if clauses should be placed first

Exact

NC3.8.2.b

Nested if...-else statements shall not be deeper than two levels. Use function calls or switch statements to reduce complexity and aid understanding

Exact

NC3.8.2.c

Assignments shall not be made within an if or else if test

Exact

NC3.8.2.d

Any if statement with an else if clause shall end with an else clause

Exact

NC3.8.3.a

The break for each case shall be indented to align with the associated case, rather than with the contents of the case code block

Exact

NC3.8.3.b

All switch statements shall contain a default block

Exact

NC3.8.3.c

Any case designed to fall through to the next shall be commented to clearly explain the absence of the corresponding break

Exact

NC3.8.4.a

Magic numbers shall not be used as the initial value or in the endpoint test of a while, do...while, or for loop

Exact

NC3.8.4.b

With the exception of the initialization of a loop counter in the first clause of a for statement and the change to the same variable in the third, no assignment shall be made in any loop’s controlling expression

Exact

NC3.8.4.c

Infinite loops shall be implemented via the controlling expression for (;;)

Exact

NC3.8.4.d

Each loop with an empty body shall feature a set of braces enclosing a comment to explain why nothing needs to be done until after the loop terminates

Process

NC3.8.5.a

The use of goto statements shall be restricted as per Rule 1.7.c

Exact

NC3.8.5.b

C Standard Library functions abort(), exit(), setjmp(), and longjmp() shall not be used

Exact

NC3.8.6.a

When evaluating the equality of a variable against a constant, the constant shall always be placed to the left of the equal-to operator ( == )

Exact

Philips-Healthcare-C++:2010

Rule PP1.CFL002

Summary

All switch statements shall have a default label as the last case label. (See page 28 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option declarations
declarations
-config=PP1.CFL002,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule PP1.CFL003

Summary

An else sub-statement of an if statement shall not be an if statement without an else part. (See page 28 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=PP1.CFL003,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule PP1.CFL004

Summary

Do not use goto. (See page 29 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option statements
statements
-config=PP1.CFL004,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=PP1.CFL004,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule PP1.CFL006

Summary

Do not apply sizeof to an expression with side-effects. (See page 29 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option effects
effects
-config=PP1.CFL006,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule PP1.CFL009

Summary

Never use continue to exit a loop. (See page 30 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option statements
statements
-config=PP1.CFL009,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=PP1.CFL009,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule PP1.CFL010

Summary

Never use break to exit a loop. (See page 30 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Rule PP1.CFL016

Summary

Do not have overly complex functions. (See page 33 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option limit
limit
-config=PP1.CFL016,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=PP1.CFL016,limit=100

Option declarations
declarations
-config=PP1.CFL016,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule PP1.CFL019

Summary

Use explicit parentheses when using multiple relational and/or logical operators in an expression. (See page 34 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=PP1.CFL019,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule PP1.CFL020

Summary

A non-void function will end with a return statement. (See page 35 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option statements
statements
-config=PP1.CFL020,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=PP1.CFL020,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=PP1.CFL020,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule PP1.CFL024

Summary

A statement must have a side-effect, i.e., it must do something. (See page 36 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Rule PP1.COM004

Summary

Use // for comments. (See page 26 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option comments
comments
-config=PP1.COM004,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule PP1.COM005

Summary

Do not leave commented-out code in the source file. (See page 26 of PH-CPP-2010 [31] .)

Description

Sections of code in the compiled files must not be commented out.

Any non-compiled sources are reported as additional information.

Configuration

See generic service options.

Option comments
comments
-config=PP1.COM005,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=PP1.COM005,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=PP1.COM005,code_lines=0

Option ignored_comments
ignored_comments
-config=PP1.COM005,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=PP1.COM005,ignored_comments=__doxygen_comments

Rule PP1.CON002

Summary

Do not cast away const. (See page 38 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option casts
casts
-config=PP1.CON002,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule PP1.CON004

Summary

Use the new cast operators (static_cast, const_cast, dynamic_cast, and reinterpret_cast) instead of the C-style casts. (See page 40 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option casts
casts
-config=PP1.CON004,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule PP1.CON006

Summary

Don’t use reinterpret_cast. (See page 40 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option casts
casts
-config=PP1.CON006,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule PP1.GEN003

Summary

Avoid pointer arithmetic. The only operators allowed on pointers are =, ==, !=, ->, [ ] (for arrays) and the unary *. (See page 49 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Rule PP1.INT004

Summary

Always specify the return type of a method/function explicitly. (See page 9 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option declarations
declarations
-config=PP1.INT004,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule PP1.INT013

Summary

Avoid methods and functions with many arguments. (See page 13 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option metric_default_fmt
metric_default_fmt
-config=PP1.INT013,metric_default_fmt=FMT

Specify the default format.

FMT:

the default format (see the -fmt global configuration content, template reprtmtc__id_default_fmt) that should be used if no other format is specified; it has fields:

subject_kind

subject kind;

subject_msg

subject message;

subject_name

subject name;

subject_named

Boolean indicating if the subject has a name;

metric_id

metric identifier;

metric_summary

metric summary;

lower_case_metric_summary

metric summary in lowercase;

context_kind

context kind;

context_name

context name;

context_desc

context description;

report_where

a tag with values incremental or final indicating where the metric is reported;

domain

the environment or entity where the metric is reported;

domain_msg

a message describing the environment or entity where the metric is reported;

limit

the metric limit;

rel

the relation used to compare the limit with the metric value;

good_limit

the metric limit that must not be exceeded;

subject_eq_context

Boolean indicating if the context and subject are the same;

value

the actual value for the metric.

Default:

-config=PP1.INT013,metric_default_fmt="%{__metric_value_gt_limit_fmt()}"

Option metric_show
metric_show
-config=PP1.INT013,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=PP1.INT013,metric_show={B.PARAM_FUNC, 7}

Option declarations
declarations
-config=PP1.INT013,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule PP1.INT027

Summary

In a derived class, if you override one of the base class’s virtual functions, then you shall declare that overriding function explicitly as virtual. (See page 19 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Rule PP1.NAM002

Summary

Do not use identifiers which begin with an underscore (‘_’) followed by a capital. (See page 51 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=PP1.NAM002,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=PP1.NAM002,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=PP1.NAM002,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=PP1.NAM002,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=PP1.NAM002,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.NAM002,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=PP1.NAM002,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule PP1.NAM003

Summary

The names of user defined types, enumerators, typedefs, typenames and class templates are in PascalCase. (See page 51 of PH-CPP-2010 [31] .)

Description

Reports if names of user defined types, enumerators, typedefs, typenames and class templates do not start with an uppercase letter or contain an underscore character

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=PP1.NAM003,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=PP1.NAM003,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=PP1.NAM003,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=PP1.NAM003,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=PP1.NAM003,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.NAM003,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=PP1.NAM003,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule PP1.NAM004

Summary

In names which consist of more than one word, the words are written together and each word that follows the first is begun with an uppercase letter. (See page 51 of PH-CPP-2010 [31] .)

Description

Reports if entity names contain an underscore

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=PP1.NAM004,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=PP1.NAM004,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=PP1.NAM004,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=PP1.NAM004,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=PP1.NAM004,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.NAM004,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=PP1.NAM004,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule PP1.NAM005

Summary

The names of data members and member functions are in PascalCase. (See page 52 of PH-CPP-2010 [31] .)

Description

Reports if member names do not start with an uppercase letter or contain an underscore character; optionally the name can be prefixed by m_

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=PP1.NAM005,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=PP1.NAM005,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=PP1.NAM005,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=PP1.NAM005,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=PP1.NAM005,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.NAM005,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=PP1.NAM005,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule PP1.NAM006

Summary

The names of formal arguments to methods/functions should be specified and should be the same both in the declaration and in the definition. (See page 52 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option declarations
declarations
-config=PP1.NAM006,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule PP1.NAM008

Summary

Do not use identifiers that contain two or more underscores in a row. (See page 53 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=PP1.NAM008,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=PP1.NAM008,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=PP1.NAM008,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=PP1.NAM008,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=PP1.NAM008,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.NAM008,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=PP1.NAM008,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule PP1.NAM014

Summary

The names of internal or local variables and internal functions are in camelCase. (See page 54 of PH-CPP-2010 [31] .)

Description

Reports if internal function names or internal or local variable names do not begin with a lowercase letter or use an underscore character

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=PP1.NAM014,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=PP1.NAM014,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=PP1.NAM014,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=PP1.NAM014,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=PP1.NAM014,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.NAM014,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=PP1.NAM014,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule PP1.OLC010

Summary

Declare each variable in a separate declaration statement. (See page 62 of PH-CPP-2010 [31] .)

Description

Each variable and function declarator must have its own personal declaration.

Configuration

See generic service options.

Rule PP1.OLC016

Summary

Do not re-declare a visible name in a nested scope. (See page 64 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Rule PP1.ORG001

Summary

Enclose all code in header files within include guards. (See page 20 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option directives
directives
-config=PP1.ORG001,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule PP1.PCA006

Summary

Do not use setjmp and longjmp. (See page 79 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option declarations
declarations
-config=PP1.PCA006,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.PCA006,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule PP1.PCA010

Summary

Do not use unions. (See page 81 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option declarations
declarations
-config=PP1.PCA010,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=PP1.PCA010,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule PP1.PCA013

Summary

Do not use trigraphs or alternative tokens. (See page 81 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Rule PP1.POR004

Summary

Do not cast a pointer to a shorter quantity to a pointer to a longer quantity. (See page 86 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option casts
casts
-config=PP1.POR004,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule PP1.POR006

Summary

Use explicit type conversions for arithmetic using signed and unsigned values. (See page 86 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option casts
casts
-config=PP1.POR006,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule PP1.POR010

Summary

Do not assume that the operands in an expression are evaluated in a definite order, unless. (See page 88 of PH-CPP-2010 [31] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule PP1.POR025

Summary

Floating point values shall not be compared using the ==, !=, >= or <= operators. (See page 92 of PH-CPP-2010 [31] .)

Description

Floating-point expressions must not be compared using ==, !=, >= or <=, == operators.

Exceptions

Note that comparison with 0.0 can be exempted using the statements service configuration.

Configuration

See generic service options.

Option statements
statements
-config=PP1.POR025,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option ignored_stmts
ignored_stmts
-config=PP1.POR025,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule PP1.POR028

Summary

Always return a value from main. (See page 93 of PH-CPP-2010 [31] .)

Description

The main function must return a value.

Configuration

See generic service options.

Option statements
statements
-config=PP1.POR028,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=PP1.POR028,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=PP1.POR028,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule PP1.POR035

Summary

Headers supplied by the standard libraries go in <> brackets; all other headers go in “”. (See page 94 of PH-CPP-2010 [31] .)

Description

Any #include directive must be followed by a filename delimited by <> for library files and by double quotes for files that are part of the source code.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=PP1.POR035,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=PP1.POR035,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule PP1.POR037

Summary

Avoid the use of #pragma warning directive. (See page 95 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=PP1.POR037,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=PP1.POR037,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=PP1.POR037,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule PP1.PRE002

Summary

Use parentheses around macro and macro parameters. (See page 96 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option param_parentheses
param_parentheses
-config=PP1.PRE002,param_parentheses=CONDS,...

Specify conditions when parameter parentheses are not required.

The configuration’s content is a short-circuit sequence of macro parameter parentheses.

CONDS:

conditions for parameter parentheses. Accepted forms are:

  • binary_op(): the parameter is an argument to a binary operator

  • unary_op(): the parameter is an argument to a unary operator

  • conditional_op(): the parameter is an argument to a conditional operator

  • pre(PRE_POST_EXPR): the tokens before the parameter must match PRE_POST_EXPR

  • post(PRE_POST_EXPR): the tokens after the parameter must match PRE_POST_EXPR

  • pre_post(PRE_POST_EXPR0,PRE_POST_EXPR1): the tokens before the parameter must match PRE_POST_EXPR0 and the tokens after the parameter must match PRE_POST_EXPR1

PRE_POST_EXPR

accepted forms are:

  • QSTRING: quoted token sequence

  • QSTRING||PRE_POST_EXPR: alternative quoted token sequences

Default:

-config=PP1.PRE002,param_parentheses="pre('->'||'.')"

Option macros
macros
-config=PP1.PRE002,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule PP1.STY002

Summary

Always use parentheses to clarify the order of expression evaluation. (See page 102 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=PP1.STY002,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule PP1.STY005

Summary

The indentation must be 4 spaces. (See page 103 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Rule PP1.STY019

Summary

Pointers to pointers should whenever possible be avoided. (See page 111 of PH-CPP-2010 [31] .)

Description

It is shown if the declared type of an object has more than 1 levels of pointer indirection.

It is also shown if the return type of a function has more than 1 levels of pointer indirection (see “Programming in C++, Rules and Recommendations”, Chapter 12).

Configuration

See generic service options.

Rule PP1.STY022

Summary

The names of macros are in uppercase. (See page 112 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=PP1.STY022,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=PP1.STY022,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=PP1.STY022,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=PP1.STY022,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=PP1.STY022,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=PP1.STY022,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=PP1.STY022,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule PP1.STY025

Summary

Do not use letters that can be mistaken for digits, and vice versa. (See page 113 of PH-CPP-2010 [31] .)

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=PP1.STY025,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=PP1.STY025,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule PP1.STY027

Summary

Do not use tabs in source code. (See page 113 of PH-CPP-2010 [31] .)

Description

The <TAB> character must not be used.

Configuration

See generic service options.

The AUTOSAR C Implementation Rules

Rule SC1.PROG_000

Summary

The language within source files shall be English throughout. (See page 13 of AUTOSAR-C-2009 [30] .)

Description

The language used must be English. Note that this service checks the words but not the grammar. To specify the vocabulary for the words, two files must be provided:

  • a context_dictionary service configuration naming an English language dictionary file, and

  • a project_dictionary service configuration naming a dictionary file containing special words, acronyms,and abbreviations allowed in the project.

See vocabulary for more information about the vocabulary dictionaries and their use.

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=SC1.PROG_000,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=SC1.PROG_000,project_dictionary=""

Option context_dictionary
context_dictionary
-config=SC1.PROG_000,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=SC1.PROG_000,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=SC1.PROG_000,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=SC1.PROG_000,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=SC1.PROG_000,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=SC1.PROG_000,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=SC1.PROG_000,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=SC1.PROG_000,max_no_case_length=16

Option good_words_file
good_words_file
-config=SC1.PROG_000,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=SC1.PROG_000,good_words_file=""

Option bad_words_file
bad_words_file
-config=SC1.PROG_000,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=SC1.PROG_000,bad_words_file=""

Option good_items_file
good_items_file
-config=SC1.PROG_000,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=SC1.PROG_000,good_items_file=""

Option bad_items_file
bad_items_file
-config=SC1.PROG_000,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=SC1.PROG_000,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=SC1.PROG_000,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=SC1.PROG_000,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=SC1.PROG_000,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=SC1.PROG_000,bad_item_regexs={}

Option comment_regexs
comment_regexs
-config=SC1.PROG_000,comment_regexs=SPLITTER,...

A list of regular expressions defining comment splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

  • SPLITTER: regular expression defining a custom splitter.


Option ignored_comments
ignored_comments
-config=SC1.PROG_000,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option comments
comments
-config=SC1.PROG_000,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule SC1.PROG_003

Summary

The interface file shall have the extension .h and the body file shall have the extension .c. (See page 13 of AUTOSAR-C-2009 [30] .)

Description

The #include directive must be followed by a filename with the extension .h; the main file must have the extension .c.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=SC1.PROG_003,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=SC1.PROG_003,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule SC1.PROG_008

Summary

There should not be more than one declaration on a line. (See page 13 of AUTOSAR-C-2009 [30] .)

Description

There must not be more than one declaration on a line.

Configuration

See generic service options.

Option contexts
contexts
-config=SC1.PROG_008,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule SC1.PROG_023

Summary

Do not insert a blank before (or after) the . and the -> operators. (See page 14 of AUTOSAR-C-2009 [30] .)

Description

There must be no space before or after the member expression . or -> operators.

The operator_space service configuration can be used to add other operators (such as the C++ operators .* and ->*).

For example, the following configuration line reports any space before or after the ->* operator:

-doc="There must be no space before or after the ->* operator."
-config=SC1.PROG_023,+operator_space={"stmt(node(binary_operator))", "any()",
   {"tag_spaces(arrow_star, space(lh, ^ $, 0)&&space(rh, ^ $, 0))"}}

Configuration

See generic service options.

Option operator_space
operator_space
-config=SC1.PROG_023,operator_space={MATCHER, CONTEXT, {TAG_SPACES,...}},...

Specify a character, such as an operator, keyword or bracket, with the required preceding and following space characters.

The configuration’s content is a list of node and context matchers with the operator tags and space position tags.

MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements. Accepted forms are:

  • decl(DECL_MATCHER): the node is a declaration that matches DECL_MATCHER> (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the node is an expression that matches TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the node is a statement that matches STMT_MATCHER (see the -stmt_selector global configuration)

CONTEXT:

a -context_selector identifier or a matcher expression used to select the contexts.

TAG_SPACES:

tagged spaces data. Accepted forms are:

  • tag_spaces(CHAR_TAGS,SPACES): tagged spaces

CHAR_TAGS

accepted forms are:

  • CHAR_TAG[||CHAR_TAG]*: character tag

CHAR_TAG

accepted forms are:

  • OPERATOR_TAG: operator tag

  • BRACK_TAG: parenthesis or square bracket tag

  • KEYWORD_TAG: keyword

  • MARKER_TAG: semicolon terminating a statement or a comma separating parameter declarations

  • OTHER_TAG: other characters

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator

BRACK_TAG

accepted forms are:

  • lbrack: left bracket of array subscript expression

  • rbrack: right bracket of array subscript expression

  • lparen: left parenthesis of a parenthesised expression

  • rparen: right parenthesis of a parenthesised expression

MARKER_TAG

accepted forms are:

  • parameter_comma: comma separating function parameters

  • semicolon: semicolon terminating a statement

OTHER_TAG

accepted forms are:

  • question: ? sigil in a conditional_operator

  • colon: : sigil in a conditional_operator

  • star: * pointer operator

  • ampersand: & pointer operator

KEYWORD_TAG

accepted forms are:

  • for: for keyword

  • while: while keyword

  • switch: switch keyword

  • return: switch keyword

SPACES

accepted forms are:

  • space(LRH,WS_SEQ,POS_MIN_MAX: on the LRH side of the operator the number of white space characters in WS_SEQ must be in the range range POS_MIN_MAX

LRH

accepted forms are:

  • lh: before the operator

  • rh: after the operator

WS_SEQ

accepted forms are:

  • WS[||WS_SEQ]*: sequence of white space or tag characters

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator

WS

accepted forms are:

  • sp_nl: a single space or a single newline optionally followed by other white space characters

  • ^REGEX$: an alternative to a space character is allowed if it matches ^REGEX$

REGEX

accepted forms are:

Default:

-config=SC1.PROG_023,operator_space={"stmt(node(member_expr))", "any()",
    {"tag_spaces(dot||arrow, space(lh, ^ $, 0)&&space(rh, ^ $, 0))"}}

Rule SC1.PROG_024

Summary

Operators ++, --, & (functionAddress) , * (FunctionRef) shall be stuck to their operand. (See page 14 of AUTOSAR-C-2009 [30] .)

Description

There must be no white space:

  • after the prefix operators ++ or --;

  • before the postfix operators ++ or --;

  • after the address-of & operator or dereference * operator.

Configuration

See generic service options.

Rule SC1.PROG_025

Summary

Unary operators ! and ~ (operators that only have a right operand) shall be stuck to their operand. (See page 15 of AUTOSAR-C-2009 [30] .)

Description

There must be no space after the logical negation operator ! or bitwise complement operator ~.

Configuration

See generic service options.

Option consecutive_operators
consecutive_operators
-config=SC1.PROG_025,consecutive_operators=CHAR_TAG

Specify characters, such as an operator, keyword or bracket, that, when it occurs consecutively, it does not require any separating space.

CHAR_TAG:

one or more character tags separated by ||. Accepted forms are:

  • OPERATOR_TAG: operator tag

  • BRACK_TAG: parenthesis or square bracket tag

  • KEYWORD_TAG: keyword

  • MARKER_TAG: semicolon terminating a statement or a comma separating parameter declarations

  • OTHER_TAG: other characters

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator

BRACK_TAG

accepted forms are:

  • lbrack: left bracket of array subscript expression

  • rbrack: right bracket of array subscript expression

  • lparen: left parenthesis of a parenthesised expression

  • rparen: right parenthesis of a parenthesised expression

MARKER_TAG

accepted forms are:

  • parameter_comma: comma separating function parameters

  • semicolon: semicolon terminating a statement

OTHER_TAG

accepted forms are:

  • question: ? sigil in a conditional_operator

  • colon: : sigil in a conditional_operator

  • star: * pointer operator

  • ampersand: & pointer operator

KEYWORD_TAG

accepted forms are:

  • for: for keyword

  • while: while keyword

  • switch: switch keyword

  • return: switch keyword


Rule SC1.PROG_030

Summary

Function comments shall be positioned in front of the function header. The function comments shall be above the functions in the C file. The function comments may also be in the H file. (See page 15 of AUTOSAR-C-2009 [30] .)

Description

For each declared function there must be a comment before one of its declarations or its definition.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=SC1.PROG_030,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option decl_document_selector
decl_document_selector
-config=SC1.PROG_030,decl_document_selector={TAGS, CTXT, DECL, CONSTR, WHERE},...

Specifies the report tags for undocumented declarations.

The configuration’s content is list of tagged declaration and context matchers with indicators.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONSTR:

number and size constraints. Accepted forms are:

  • LIM: number or size constraint

  • LIM&&LIMS: the comments satisfy LIM and LIMS

LIM

accepted forms are:

  • num(EXPR): the minimum number of comments is specified by EXPR

  • size(EXPR): the minimum number of characters in the comments is specified by EXPR

EXPR

accepted forms are:

  • STRING: arithmetic expression whose variables are metrics

WHERE:

specifies where the explanatory comments are supposed to be found. Accepted values are:

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;

  • doxygen: doxygen-style comments;


Option declarations
declarations
-config=SC1.PROG_030,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_034

Summary

Identifiers shall not contain the ‘_‘ character twice in succession. (See page 16 of AUTOSAR-C-2009 [30] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=SC1.PROG_034,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=SC1.PROG_034,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=SC1.PROG_034,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=SC1.PROG_034,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=SC1.PROG_034,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=SC1.PROG_034,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=SC1.PROG_034,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule SC1.PROG_038

Summary

Constants defined as a macro shall be written in upper case. Digits and underscores are allowed but not at the start. (See page 16 of AUTOSAR-C-2009 [30] .)

Description

Reports if the names of macros defining constant values do not begin with an uppercase letter followed only by uppercase, numerals and underscore characters

Configuration

See generic service options.

Option statements
statements
-config=SC1.PROG_038,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=SC1.PROG_038,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule SC1.PROG_042

Summary

Header files which are a part of predefined program libraries shall be included using <>. (See page 17 of AUTOSAR-C-2009 [30] .)

Description

Any #include directive must be followed by a filename delimited by <> for library files and by double quotes for files that are part of the source code.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=SC1.PROG_042,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=SC1.PROG_042,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule SC1.PROG_044

Summary

Each header file shall protect itself against multiple inclusion. (See page 17 of AUTOSAR-C-2009 [30] .)

Description

Any header file that does not use a mechanism to prevent multiple inclusions is shown.

Configuration

See generic service options.

Option directives
directives
-config=SC1.PROG_044,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule SC1.PROG_048

Summary

Each module shall include its own header file. (See page 17 of AUTOSAR-C-2009 [30] .)

Description

The main file NAME.c must include a header file NAME.h.

Configuration

See generic service options.

Rule SC1.PROG_050

Summary

A .c file shall not be included in another file: it shall be compiled and provided as an object module. (See page 18 of AUTOSAR-C-2009 [30] .)

Description

Files with a .c extension must not be included.

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=SC1.PROG_050,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=SC1.PROG_050,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule SC1.PROG_055

Summary

A declaration with storage-class specifier extern shall exist for each global function in the header file of the module. (See page 18 of AUTOSAR-C-2009 [30] .)

Description

The main file must not contain declarations of global variables.

Configuration

See generic service options.

Option declarations
declarations
-config=SC1.PROG_055,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_056

Summary

Declaration and definition of local functions shall have the storage-class specifier static. Local function means function with internal linkage (only visible inside the module). (See page 20 of AUTOSAR-C-2009 [30] .)

Description

A function will be reported if all the following hold:

  • all references to it are in the same unit;

  • the declaration or definition is not in a public API file.

  • it is not explicitly declared static.

A file can be declared part of a public API using the -file_tag and -public_files global configurations. For example, with the configuration lines:

-file_tag+={public_extra, "^my_public_header.h$"}
-public_files+=public_extra

functions declared in files whose names match the regular expression ^my_public_header.h$ will not be reported.

Configuration

See generic service options.

Option declarations
declarations
-config=SC1.PROG_056,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_057

Summary

Variables shall not be defined within in a .h file. They shall be defined within the module’s C file. (See page 19 of AUTOSAR-C-2009 [30] .)

Description

There must be no variable definition in a header file (file ending with .h).

Configuration

See generic service options.

Option declarations
declarations
-config=SC1.PROG_057,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_058

Summary

Each self-defined type has to have an explicit type declaration even if there is only one variable of this type. (See page 20 of AUTOSAR-C-2009 [30] .)

Description

An anonymous struct or union type must not be embedded in a variable declaration.

Configuration

See generic service options.

Option declarations
declarations
-config=SC1.PROG_058,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_061

Summary

Functions (other than macros) shall not be defined within a .h file. (See page 19 of AUTOSAR-C-2009 [30] .)

Description

There must be no function definition in a header file (file ending with .h).

Configuration

See generic service options.

Option declarations
declarations
-config=SC1.PROG_061,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_062

Summary

Declarations of functions shall always be stated with detailed parameter list, i.e. the type and a practical designation of the relevant parameters. Designator names in C and H file shall be identical. (See page 19 of AUTOSAR-C-2009 [30] .)

Description

Checks that

  • each function declaration is a prototype declaration;

  • each parameter declaration has an identifier;

  • parameter declarations that are in matching positions in two declarations or definitions for the same function have the same identifiers.

Configuration

See generic service options.

Option declarations
declarations
-config=SC1.PROG_062,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_063

Summary

External declarations of global variables shall be done in header files and never in .c files. (See page 18 of AUTOSAR-C-2009 [30] .)

Description

The main file must not contain declarations of global variables.

Configuration

See generic service options.

Option declarations
declarations
-config=SC1.PROG_063,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SC1.PROG_071

Summary

Multiple assignments shall not be done. (See page 20 of AUTOSAR-C-2009 [30] .)

Description

The assignment operators must not be used as the right-hand operand of another assignment.

Configuration

See generic service options.

Option statements
statements
-config=SC1.PROG_071,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=SC1.PROG_071,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule SC1.PROG_072

Summary

The use of ++ and -- should be limited to simple cases. They shall not be used in statements where other operators occur. The prefix use is always forbidden. (See page 21 of AUTOSAR-C-2009 [30] .)

Description

Reports if:

  • pre-increment and pre-decrement operators are used,

  • post-increment and post-decrement operators are used in assignment, mathematical or logical expressions.

Configuration

See generic service options.

Option statements
statements
-config=SC1.PROG_072,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=SC1.PROG_072,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule SC1.PROG_087

Summary

Brackets shall always be used in complex expressions even if the C priority rules do not necessarily demand this for operators. This also applies to expressions evaluated by the preprocessor. (See page 14 of AUTOSAR-C-2009 [30] .)

Description

Reports an expression if any of the following hold:

  • the operand of sizeof or _Alignof is not in parentheses;

  • the precedence P of the main operator is between 3 and 12 and the precedence of the operand is strictly greater than P and no more than 12.

Note that the following operators and their precedences (as written in the MISRA C document) are assumed:

12 Multiplicative  * / %
11 Additive        + -
10 Bitwise Shift   << >>
9  Relational      < <= > >=
8  Equality        == !=
7  Bitwise AND     &
6  Bitwise XOR     ^
5  Bitwise OR      |
4  Logical AND     &&
3  Logical OR      ||

The trusted_pairs service configuration can be used to specify report tags for selected pairs of operators where the first matches the expression’s main operator and the second matches an operator of one of its operands. For example:

-doc="Programmers are aware of the precedence between relational and arithmetic operators, no developer confusion possible."
-config=SC1.PROG_087,trusted_pairs={safe, relational:arithmetic}

will deviate reports for expressions such as a > b+c and b+c < a.

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=SC1.PROG_087,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


AUTOSAR C Implementation Rules Coverage

This section presents a concise summary of the coverage provided by this version of ECLAIR for the AUTOSAR C Implementation Rules [30].

For all rules, the mapping between the rules and the ECLAIR service identifiers is one-to-one and straightforward. e.g., AUTOSAR C Implementation Rule PROG_034 maps to ECLAIR service SC1.PROG_034.

The table adopts the following conventions:

  • The Id column contains the ECLAIR service identifier.

  • The Headline column gives the guideline headline as published in the coding standard source.

  • The Precision column provides an indication of the precision of the ECLAIR service with respect to the guideline. More precisely, that column contains:

    • Exact, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report.

    • Precise, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every non-compliance is reported as a violation report; false positives are only possible in unreachable code.

    • Complete, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report.

    • Safe, when, to the best of our knowledge, the interpretation of the guideline given in the ECLAIR manual is what is implemented by the ECLAIR service and every possible non-compliance is reported as a violation report or, when the service cannot be sure of non-compliance, as a caution report; violation reports that are false positives are only possible in unreachable code.

    • Heuristic, when the ECLAIR service for a guideline that is intrinsically vague because human judgement is needed, uses a heuristic aimed at reducing the number of likely false positives and false negatives.

    • Best-effort, when the ECLAIR service does not report all the non-compliances of the guideline, when the guideline is interpreted as explained in the ECLAIR manual.

    • Process, when the guideline does not ask for specific results but for the adoption of means and/or processes.

    Note that, for reachable code, every violation report shows a true non-compliance of the guideline, while a caution report may show code that is not a non-compliance.

    For non-exact ECLAIR services, hints about the reasons for the imprecision are included in the detailed guideline descriptions.

SC1 synopsis: supported AUTOSAR C Implementation Rules

Id

Headline

Precision

SC1.PROG_000

The language within source files shall be English throughout

Exact

SC1.PROG_003

The interface file shall have the extension .h and the body file shall have the extension .c

Exact

SC1.PROG_008

There should not be more than one declaration on a line

Exact

SC1.PROG_023

Do not insert a blank before (or after) the . and the -> operators

Exact

SC1.PROG_024

Operators ++, --, & (functionAddress) , * (FunctionRef) shall be stuck to their operand

Exact

SC1.PROG_025

Unary operators ! and ~ (operators that only have a right operand) shall be stuck to their operand

Exact

SC1.PROG_030

Function comments shall be positioned in front of the function header. The function comments shall be above the functions in the C file. The function comments may also be in the H file

Exact

SC1.PROG_034

Identifiers shall not contain the ‘_‘ character twice in succession

Exact

SC1.PROG_038

Constants defined as a macro shall be written in upper case. Digits and underscores are allowed but not at the start

Exact

SC1.PROG_042

Header files which are a part of predefined program libraries shall be included using <>

Exact

SC1.PROG_044

Each header file shall protect itself against multiple inclusion

Exact

SC1.PROG_048

Each module shall include its own header file

Exact

SC1.PROG_050

A .c file shall not be included in another file: it shall be compiled and provided as an object module

Exact

SC1.PROG_055

A declaration with storage-class specifier extern shall exist for each global function in the header file of the module

Exact

SC1.PROG_056

Declaration and definition of local functions shall have the storage-class specifier static. Local function means function with internal linkage (only visible inside the module)

Exact

SC1.PROG_057

Variables shall not be defined within in a .h file. They shall be defined within the module’s C file

Exact

SC1.PROG_058

Each self-defined type has to have an explicit type declaration even if there is only one variable of this type

Exact

SC1.PROG_061

Functions (other than macros) shall not be defined within a .h file

Exact

SC1.PROG_062

Declarations of functions shall always be stated with detailed parameter list, i.e. the type and a practical designation of the relevant parameters. Designator names in C and H file shall be identical

Exact

SC1.PROG_063

External declarations of global variables shall be done in header files and never in .c files

Exact

SC1.PROG_071

Multiple assignments shall not be done

Exact

SC1.PROG_072

The use of ++ and -- should be limited to simple cases. They shall not be used in statements where other operators occur. The prefix use is always forbidden

Exact

SC1.PROG_087

Brackets shall always be used in complex expressions even if the C priority rules do not necessarily demand this for operators. This also applies to expressions evaluated by the preprocessor

Exact

The Altran rules

Rule SCSTD.24

Summary

Comments and Description shall be done following Doxygen [7] semantics and syntax along with ANSI C 90 comment style (/*...*/).

Description

Comments must use the /* ... */ style.

Code must use valid doxygen comments.

Note that all parameters should be documented with a separate \param description.

The doxygen_text_regex service configuration can be used suppress the report for the specified doxygen command with text regular expression.

Configuration

See generic service options.

Option doxygen_text_regex
doxygen_text_regex
-config=SCSTD.24,doxygen_text_regex={TAGS, COMMAND, REGEX},...

Specify tags for commands with the matching doxygen lines.

The configuration’s content is a tuple with three terms: a report tag, a doxygen command and a regular expression.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMAND:

doxygen command. Accepted values are:

  • return: return command;

  • param: param command;

  • tparam: tparam command;

  • unknown: unknown command;

  • union: union command;

  • struct: struct command;

  • class: class command;

  • function: function command;

  • callback: callback command;

  • brief: brief command;

  • deprecated: deprecated command;

REGEX:

if the text following COMMAND matches REGEX, then any report will be tagged by TAG.


Option comments
comments
-config=SCSTD.24,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule SCSTD.49

Summary

Functions shall have prototype declarations visible at both function definition and call.

Description

Reports:

  • a function declaration or definition that does not have a function prototype;

  • a reference to a function before a prototype declaration or definition of the function;

  • a function with external linkage defined in the compilation main file that does not have a previous prototype declaration that is located in a header file;

  • a function with internal linkage defined in the compilation main file that does not have a previous prototype declaration.

Configuration

See generic service options.

Option declarations
declarations
-config=SCSTD.49,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule SCSTD.56

Summary

Numbers should not be used directly in the code, use of constants is recommended.

Configuration

See generic service options.

Option literals
literals
-config=SCSTD.56,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule SCSTD.82

Summary

A function shall have a single point of exit at the end of the function.

Configuration

See generic service options.

Option exit_kind
exit_kind
-config=SCSTD.82,exit_kind={KIND, WHERE, NEST},...

Specify the exit nodes and conditions on the allowed contexts for these nodes to be used as exit points in the function definition.

The configuration’s content is a list of exit kinds with conditions on the positions of nodes with these kinds in the function definition.

KIND:

nodes with the selected exit kinds are called exit nodes. Accepted values are:

  • return: a return statement is an exit node;

  • noreturn_call: any call to a function with noreturn attribute/property is an exit node (to specify the function call property see the -call_properties global configuration);

  • throw: a throw expression is an exit node;

WHERE:

indicate whether the exit node should only be the last statement of an end context (end position) or may also occur elsewhere in the function body. Accepted values are:

  • only_at_end_position: the associated exit node may only occur in a designated end position;

  • anywhere: the associated exit node may occur anywhere;

NEST:

whether the end position can be in a nested compound statement. Accepted values are:

  • true: the end position can be in a nested compound statement;

  • false: the end position cannot be in a nested compound statement;

Default:

-config=SCSTD.82,exit_kind={return, only_at_end_position, true},
  {noreturn_call, anywhere, true}

Option end_position
end_position
-config=SCSTD.82,end_position={{POS,...}, END},...

Specify the end positions and if an exit node is required.

The configuration’s content is a list of the end positions and if a exit kind node is required at that position.

{POS,…}:

end position in the function body. Accepted members are:

  • compound: the end of the body when the body is a compound statement;

  • try: the end of the body when the body is a try block;

  • catch: the end of a catch handler when the body is a try block;

  • compound_try: the end of a try block when last statement of the function body is the try block;

  • compound_catch: the end of a catch handler when last statement of the function body is the handled try block;

END:

whether the exit position must always have an exit kind node. Accepted values are:

  • true: the exit position must always have an exit node;

  • false: the exit position does not have to have an exit node;

Default:

-config=SCSTD.82,end_position={{compound, try}, false}

The Language Standard Behaviors

The ECLAIR ancillary services for language standard behaviors are provided by BUGSENG to support ECLAIR services that report on issues concerning C and C++ code standards and portability.

These ancillary services do not need to be specifically enabled since all the required services will be enabled automatically by the ECLAIR services they support.

Note that the identifier for each of the ECLAIR ancillary services described in this section has the prefix STD..

Rule STD.abortbhr

Summary

Whether open streams with unwritten buffered data are flushed, open streams are closed, or temporary files are removed when the abort or _Exit function is called.

Description

Reports uses of the abort function in <stdlib.h> when the behavior about temporary files is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.abortbhr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.abortbhr,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.abortbhr,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.abortbhr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.adrslabl

Summary

An address label expression.

Description

Reports the uses of an address of a label.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.adrslabl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.adrslabl,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.adrslabl,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.adrslabl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.anonfild

Summary

An unnamed field that is not a bit-field.

Description

Reports unnamed members that are not bit-fields.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.anonfild,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.anonfild,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.anonfild,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.anonstct

Summary

A structure or union is defined as containing no named members.

Description

Reports struct/union containing no named member.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.anonstct,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.anonstct,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.anonstct,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.araystat

Summary

A static modifier in an array declaration.

Description

Reports static modifiers in an array type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.araystat,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.araystat,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.araystat,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.arayzero

Summary

A zero size array type.

Description

Reports zero length array types.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.arayzero,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option types
types
-config=STD.arayzero,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.arayzero,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.arayzero,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.argdrctv

Summary

There are sequences of preprocessing tokens within the list of macro arguments that would otherwise act as preprocessing directives.

Description

Reports when the arguments to a call to a function-like macro are a single # or contain a # followed by a directive name (other than as part of a comment, character literal or string literal).

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.argdrctv,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.argdrctv,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.argdrctv,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.argfcall

Summary

Arguments in one function call.

Description

Reports infringement of the limit for arguments in one function call.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of arguments in one function call and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.argfcall,behavior={c99, "^gcc[^/]*$", "256"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of arguments in one function call is 256>.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.argfcall,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.argfcall,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Rule STD.argmcall

Summary

Arguments in one macro invocation.

Description

Reports infringements of the limit for arguments in one macro invocation.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of arguments in one macro invocation and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.argmcall,behavior={c99, "^gcc[^/]*$", "256"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of arguments in one macro invocation is 256>.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.argmcall,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.argmcall,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.arthinvl

Summary

An exceptional condition occurs during the evaluation of an expression.

Description

Reports expressions whose evaluation generates an exception.

Note that, for this service, the report category is the diagnostic identifier.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for expressions whose evaluation may generate an exception and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.arthinvl,behavior={c99, "^gcc[^/]*$",
   "name(warn_remainder_division_by_zero)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning warn_remainder_division_by_zero is understood.

Implementation

Currently, only the diagnostic warning for divide-by-zero and integer constant overflow are implemented.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.arthinvl,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.arthinvl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.asrtterm

Summary

The format of the diagnostic printed by the assert macro.

Description

Reports uses of the assert function/macro in <assert.h> when the diagnostic format is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.asrtterm,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.asrtterm,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.asrtterm,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Option declarations
declarations
-config=STD.asrtterm,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.bincondl

Summary

A binary conditional expression.

Description

Reports binary conditional operators.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bincondl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.bincondl,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.bincondl,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.bincondl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.bitfldby

Summary

Whether a bit-field can straddle a storage-unit boundary.

Description

Reports uses of bit-fields when it is relevant if they may straddle a storage unit boundary.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bitfldby,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all bit-field uses.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.bitfldby,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.bitfldor

Summary

The order of allocation of bit-fields within a unit.

Description

Reports bit-fields when the order of allocation is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bitfldor,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all bit-field uses.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.bitfldor,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.bitfldtp

Summary

Non-standard bit-field types.

Description

Reports bit-fields with non-standard types.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bitfldtp,behavior={c99, "^gcc[^/]*$", "long;unsigned long"}

indicates that the behavior for bit-fields with type long or unsigned long is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.bitfldtp,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=STD.bitfldtp,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option behavior
behavior
-config=STD.bitfldtp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify undefined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

implemented bitfield types. Accepted forms are:

  • BITFIELD[;BITFIELD]*: the bitfield type matches one of BITFIELD

BITFIELD

accepted forms are:

  • enum: the bitfield type is an enumerator type

  • BUILTIN_INTEGRAL: the bitfield type is a BUILTIN_INTEGRAL

BUILTIN_INTEGRAL

accepted forms are:

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

  • signed char: signed char

  • long long: long long

  • long: long

  • short: short

  • int: int

  • _Bool: _Bool

  • __int128_t: __int128_t

  • __uint128_t: __uint128_t

  • bool: bool

  • char: char

  • char8_t: char8_t

  • char16_t: char16_t

  • char32_t: char32_t


Rule STD.bitfsign

Summary

Implementation-signed bit-field types.

Description

Reports bit-fields with implicit signedness.

The behavior service configuration with its associated -doc line can be used to specify the bit-fields with implicit signedness and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bitfsign,behavior={c99, "^gcc[^/]*$", "long;unsigned long"}

indicates that the behavior for bit-fields with type long or unsigned long is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.bitfsign,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=STD.bitfsign,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option behavior
behavior
-config=STD.bitfsign,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify undefined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

implemented bitfield types. Accepted forms are:

  • BITFIELD[;BITFIELD]*: the bitfield type matches one of BITFIELD

BITFIELD

accepted forms are:

  • enum: the bitfield type is an enumerator type

  • BUILTIN_INTEGRAL: the bitfield type is a BUILTIN_INTEGRAL

BUILTIN_INTEGRAL

accepted forms are:

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

  • signed char: signed char

  • long long: long long

  • long: long

  • short: short

  • int: int

  • _Bool: _Bool

  • __int128_t: __int128_t

  • __uint128_t: __uint128_t

  • bool: bool

  • char: char

  • char8_t: char8_t

  • char16_t: char16_t

  • char32_t: char32_t


Rule STD.bitfwdth

Summary

If the specified width of a bit-field exceeds the maximum number of bits in its type.

Description

Reports bit-fields when it is relevant if the width exceeds the size of the type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bitfwdth,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.bitfwdth,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=STD.bitfwdth,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option behavior
behavior
-config=STD.bitfwdth,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.bitopsgn

Summary

The results of some bitwise operations on signed integers.

Description

Reports bitwise operations on signed integers.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bitopsgn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.bitopsgn,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.bitopsgn,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.bitopsgn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.blkident

Summary

Identifiers with block scope declared in one block.

Description

Reports infringements of the limit for identifiers with block scope declared in one block.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of identifiers with block scope declared in one block and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.blkident,behavior={c99, "^gcc[^/]*$", "512"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of identifiers with block scope declared in one block is 512>.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.blkident,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.blkident,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.bsercheq

Summary

Which of two elements that compare as equal is matched by the bsearch function.

Description

Reports uses of the bsearch function in <stdlib.h> when the element chosen from those that compare as equal is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bsercheq,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.bsercheq,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.bsercheq,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.bsercheq,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.bytebits

Summary

The number of bits in a byte.

Description

Reports if the number of bits in a byte is unspecified or incongruent.

The behavior service configuration with its associated -doc line can be used to specify the number of bits in a byte and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.bytebits,behavior={c99, "^gcc[^/]*$", "16"}

indicates that the number of bits in a byte is 16 for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.bytebits,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify implementation-defined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

number of bits in a byte. Accepted forms are:

  • NUM_BITS: number of bits


Rule STD.byteobjt

Summary

Bytes in an object (in a hosted environment only).

Description

Reports infringements of the limit for bytes in an object (in a hosted environment only).

The behavior service configuration with its associated -doc line can be used to specify the maximum number of bytes in an object and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.byteobjt,behavior={c99, "^gcc[^/]*$", "262144"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of bytes in an object is 262144.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.byteobjt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.byteobjt,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.caselimt

Summary

case labels for a switch statement (excluding those for any nested switch statements).

Description

Reports infringements of the limit for the number of case statements in a switch statement.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of case statements in a switch statement and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.caselimt,behavior={c99, "^gcc[^/]*$", "1023"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of case statements in a switch statement is 1023>.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.caselimt,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.caselimt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Rule STD.caseuplw

Summary

A case label with upper/lower values.

Description

Reports case labels with upper/lower values.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.caseuplw,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.caseuplw,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.caseuplw,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.caseuplw,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.castunon

Summary

A cast to a union type.

Description

Reports casts to union type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.castunon,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.castunon,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.castunon,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.charescp

Summary

An unspecified escape sequence is encountered in a character constant or a string literal.

Description

Reports non-standard escape sequences.

The behavior service configuration with its associated -doc line can be used to specify the non-standard escape sequences and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charescp,behavior={c99, "^gcc[^/]*$", "^[cd]$"}

indicates that the behavior for non-standard escape sequence characters c and d is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Note that, for this service, the report category is the reported escape character.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charescp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify non-standard behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

escape character.the escape characters can be any of the characters in CHOICE.


Rule STD.charlcle

Summary

The current locale used to convert a wide character constant consisting of a single multibyte character that maps to a member of the extended execution character set into a corresponding wide character code.

Description

Reports uses of multbyte characters in a wide character literal.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charlcle,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charlcle,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.charline

Summary

Characters in a logical source line.

Description

Reports infringement of the limit for characters in a logical source line.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of characters in a logical source line and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charline,behavior={c99, "^gcc[^/]*$", "4095"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of characters in a logical source line is 4095.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charline,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.charline,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.charmmap

Summary

The shift states used for the encoding of multibyte characters.

Description

Reports multibyte characters when the shift states used for the encoding is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charmmap,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charmmap,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.charmult

Summary

The value of a wide character constant containing more than one multibyte character, or containing a multibyte character or escape sequence not represented in the extended execution character set.

Description

Reports uses of multibyte characters in a wide character literal.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charmult,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charmult,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.charppif

Summary

Whether the value of a single-character character constant in a constant expression that controls conditional inclusion may have a negative value.

Description

Reports #if and #elif directives with a character constant when it is relevant if the constant could have a negative value.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charppif,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all character constants.

All character constants in the conditions for #if and #elif directives are reported as cautions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charppif,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.charppim

Summary

Whether the value of a character constant in a constant expression that controls conditional inclusion matches the value of the same character constant in the execution character set.

Description

Reports #if and #elif directives with a character constant when it is relevant if the value matches the execution character set.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charppim,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all character constants.

All character constants in the conditions for #if and #elif directives are reported as cautions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charppim,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.charset

Summary

A character not in the basic source character set is encountered in a source file, except in an identifier, a character constant, a string literal, a header name, a comment, or a preprocessing token that is never converted to a token.

Description

Reports uses of characters not in the specified character set.

The behavior service configuration with its associated -doc line can be used to specify the used character set and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charset,behavior={c99, "^gcc[^/]*$", "ascii"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the supported character set is ASCII.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charset,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • c90: the standard character set

  • ascii: the ASCII character set

  • utf8: the UTF-8 character set

  • STRING: the allowed characters


Rule STD.charsmap

Summary

The mapping of members of the source character set (in character constants and string literals) to members of the execution character set.

Description

Reports if the mapping of members of the source character set (in character constants and string literals) to members of the execution character set is unspecified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charsmap,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charsmap,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.charsmem

Summary

Additional members of the source and execution character sets beyond the basic character set.

Description

Reports uses of non-standard characters when they are not in a specified set.

The behavior service configuration with its associated -doc line can be used to specify the used character set and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charsmem,behavior={c99, "^gcc[^/]*$", "ascii"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the supported character set is ASCII.

Note that, for this service, the report category is the reported character.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charsmem,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify implementation-defined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • c90: the standard character set

  • ascii: the ASCII character set

  • utf8: the UTF-8 character set

  • STRING: the allowed characters


Rule STD.charsobj

Summary

The value of a char object into which has been stored any character other than a member of the basic execution character set.

Description

Reports uses of non-standard characters when they are not in a specified set.

The behavior service configuration with its associated -doc line can be used to specify the used character set and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charsobj,behavior={c99, "^gcc[^/]*$", "ascii"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the supported character set is ASCII.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charsobj,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • c90: the standard character set

  • ascii: the ASCII character set

  • utf8: the UTF-8 character set

  • STRING: the allowed characters


Rule STD.charstrl

Summary

Characters in a string literal (after concatenation).

Description

Reports infringements of the limit for characters in a string literal (after concatenation).

The behavior service configuration with its associated -doc line can be used to specify the maximum number of characters in a string literal and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charstrl,behavior={c99, "^gcc[^/]*$", "4095"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of characters in a string literal is 4095.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charstrl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.charstrl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.charsval

Summary

The value of an integer character constant that contains a character or escape sequence not represented in the basic execution character set or the extended character set for a wide character constant.

Description

Reports character literals that contain an unspecified character or escape sequence.

The behavior service configuration with its associated -doc line can be used to specify the used character set and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.charsval,behavior={c99, "^gcc[^/]*$", "ascii"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the supported character set is ASCII.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charsval,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • c90: the standard character set

  • ascii: the ASCII character set

  • utf8: the UTF-8 character set

  • STRING: the allowed characters


Rule STD.charxwde

Summary

A character string literal token is adjacent to a wide string literal token.

Description

Reports uses of a character string literal token adjacent to a wide string literal token.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.charxwde,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.charxwde,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.cissnest

Summary

Nesting levels of blocks.

Description

Reports infringements of the limit for nesting levels of compound statements, iteration control structures, and selection control structures.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of nesting levels of compound statements etc., and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.cissnest,behavior={c99, "^gcc[^/]*$", "127"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of nesting levels of compound statements etc., is 127.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.cissnest,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.cissnest,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.clockera

Summary

The era for the clock function.

Description

Reports uses of the clock function in <time.h> when the era is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.clockera,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.clockera,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.clockera,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.clockera,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.cmntstle

Summary

A C++-style comment.

Description

Reports uses of the non-standard // comment style.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.cmntstle,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option comments
comments
-config=STD.cmntstle,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option behavior
behavior
-config=STD.cmntstle,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.cmpdltrl

Summary

A compound literal expression.

Description

Reports compound literal expressions.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.cmpdltrl,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.cmpdltrl,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.cmpdltrl,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.cmpdltrl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.cmralloc

Summary

Whether the calloc, malloc, and realloc functions return a null pointer or a pointer to an allocated object when the size requested is zero.

Description

Reports uses of calloc, malloc or realloc functions in <stdlib.h> when the behavior with size as zero is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.cmralloc,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.cmralloc,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.cmralloc,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.cmralloc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.cnstenum

Summary

Enumeration constants in a single enumeration.

Description

Reports infringements of the limit for enumeration constants in a single enumeration.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of enumeration constants and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.cnstenum,behavior={c99, "^gcc[^/]*$", "1023"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of enumeration constants is 1023.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.cnstenum,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.cnstenum,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.cnstexpr

Summary

out-of-line redeclarations of constexpr declarations with no initializer.

Description

Reports out-of-line redeclarations of constexpr declarations with no initializer.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.cnstexpr,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.cnstexpr,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.cnstexpr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.codecvt

Summary

Use of the header codecvt and its contents.

Description

Reports use of the header codecvt and its contents.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.codecvt,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.codecvt,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.codecvt,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.codecvt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.constobj

Summary

An attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type.

Description

Reports attempts to modify objects defined with a const-qualified type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.constobj,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.constobj,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.constobj,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.cppheads

Summary

the C++ standard library headers ccomplex, cstdalign, cstdbool, and ctgmath.

Description

Reports inclusion of the C++ standard library headers ccomplex, cstdalign, cstdbool and ctgmath.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.cppheads,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.cppheads,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ctypechr

Summary

The sets of characters tested for by the isalnum, isalpha, iscntrl, islower, isprint, and isupper functions.

Description

Reports uses of isalnum, isalpha, iscntrl, islower, isprint, and isupper functions/macros in <ctype.h> when the set of characters tested is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ctypechr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.ctypechr,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.ctypechr,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.ctypechr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.datetime

Summary

The definitions for __DATE__ and __TIME__ when respectively, the date and time of translation are not available.

Description

Reports uses of the macros __DATE__ and __TIME__ when the date or time of translation is not available and their definitions are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.datetime,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all uses of __DATE__ and __TIME__.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.datetime,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.decllimt

Summary

Pointer, array, and function declarators (in any combinations) modifying an arithmetic, a structure, a union, or an incomplete type in a declaration.

Description

Reports infringements of the limit for pointer, array, and function types in a declaration.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of pointer, array, and function types in a declaration and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.decllimt,behavior={c99, "^gcc[^/]*$", "12"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of pointer, array, and function types in a declaration is 12.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.decllimt,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.decllimt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Rule STD.declmixd

Summary

A block scoped declaration not at the beginning of a compound statement.

Description

Reports block scope declarations that are not at the start of a compound statement.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.declmixd,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.declmixd,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.decltype

Summary

A typedef, variable or function declaration without an explicit type.

Description

Reports variable or function declarations whose type is not stated.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.decltype,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.decltype,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.decltype,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.defalloc

Summary

Use of deprecated types and members in the default allocator class.

Description

Use of deprecated types and members in the default allocator class.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.defalloc,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.defalloc,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.defalloc,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.defalloc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.defined

Summary

The token defined is generated during the expansion of a #if or #elif preprocessing directive, or the use of the defined unary operator does not match one of the two specified forms prior to macro replacement.

Description

Reports uses of the token defined that is generated during the expansion of a #if or #elif directive.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for the token defined that is generated during the expansion of a #if or #elif directive and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.defined,behavior={c99, "^gcc[^/]*$",
   "name(warn_defined_in_function_type_macro)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning warn_defined_in_function_type_macro is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.defined,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.defined,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.deprdiag

Summary

use of deprecated uncaught_exception.

Description

Reports use of uncaught_exception.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.deprdiag,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.deprdiag,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.deprdiag,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.desginit

Summary

A designated initializer.

Description

Reports designated initializer expressions.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.desginit,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.desginit,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.desginit,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.desginit,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.diag

Summary

An ill-formed source detected by the parser.

Description

Reports non-standard constructs reported by the parser that are not checked by other services.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.diag,behavior={c99, "^gcc[^/]*$",
   "name(ext_pp_extra_tokens_at_eol)||name(ext_warn_duplicate_declspec)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warnings ext_pp_extra_tokens_at_eol and ext_warn_duplicate_declspec is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.diag,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.diag,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.diagidnt

Summary

How a diagnostic is identified.

Description

Reports if the identification of compiler diagnostics is unspecified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.diagidnt,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.diagidnt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.divrmsgn

Summary

The sign of the remainder on integer division.

Description

Reports integer divisions when rounding strategy is relevant.

The behavior service configuration with its associated -doc line can be used to specify the integer divisions rounding strategy and its documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.divrmsgn,behavior={c90, "^gcc[^/]*$", "truncated"}

indicates that with the C90 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that any integer division remainder is truncated.

Imprecision

Cautions are reported when the relevance of the rounding strategy is not known.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.divrmsgn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify implementation-defined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

rounding. Accepted values are:

  • floored: the remainder is floored;

  • ceiled: the remainder is ceiled;

  • rounded: the remainder is rounded;

  • truncated: the remainder is truncated;

  • truncated_ada_mod: the remainder is truncated as in Ada;


Rule STD.dupldecl

Summary

A duplicate declaration specifier.

Description

Reports duplicate declaration specifiers.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.dupldecl,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.dupldecl,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.dupldecl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.emptdecl

Summary

An empty declaration.

Description

Reports empty declarations.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.emptdecl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.emptdecl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.emptdecl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.emptenum

Summary

An incomplete enum declaration.

Description

Reports incomplete enum declarations.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.emptenum,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard

Configuration

See generic service options.

Option declarations
declarations
-config=STD.emptenum,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.emptenum,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.emptinit

Summary

An empty initialization list.

Description

Reports empty initialization lists.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.emptinit,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.emptinit,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.emptinit,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.emptinit,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.emptmarg

Summary

A macro invocation with empty or extra arguments.

Description

Reports macro invocations that have empty arguments.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.emptmarg,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.emptmarg,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.encderor

Summary

The conversion state after an encoding error occurs.

Description

Reports uses of mbrtowc, wcrtomb, mbsrtowc and wcsrtomb functions in <wchar.h> when the conversion state after an encoding error is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.encderor,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.encderor,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.encderor,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.encderor,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.enumlist

Summary

An enumerator list ending with comma.

Description

Reports enumerator lists that end with a comma.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.enumlist,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.enumlist,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.enumtype

Summary

The integer type compatible with each enumerated type.

Description

Reports enum definitions when the underlying type is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.enumtype,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.enumtype,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.enumtype,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.eofnl

Summary

A nonempty source file does not end in a new-line character, ends in new-line character immediately preceded by a backslash character, or ends in a partial preprocessing token or comment.

Description

Reports nonempty source files not ending in a new-line character.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.eofnl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.eofnl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.errnofgt

Summary

The value to which the macro errno is set by the fgetpos or ftell function on failure.

Description

Reports uses of fgetpos or ftell functions in <stdio.h> when this suggests the relevance of the value of errno on failure.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.errnofgt,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.errnofgt,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.errnofgt,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.errnofgt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.execvals

Summary

The values of the members of the execution character set.

Description

Reports if the execution character values are unspecified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.execvals,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.execvals,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.exitstat

Summary

The termination status returned to the host environment by the abort, exit, or _Exit function.

Description

Reports uses of a hosted environment when the exit status is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.exitstat,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all hosted environments.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.exitstat,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence for the standard and compiler.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior for the environment is specified


Rule STD.extident

Summary

External identifiers in one translation unit.

Description

Reports infringements of the limit for external identifiers in one translation unit.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of external identifiers and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.extident,behavior={c99, "^gcc[^/]*$", "511"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of external identifiers is 511.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.extident,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.extident,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.extidsig

Summary

The number of significant initial characters in an identifier with external linkage. Whether case distinctions are significant in an identifier with external linkage.

Description

Reports distinct external identifiers that are considered the same by the toolchain according to case and length significance. Note that the standard limits for external identifiers are:

  • for C90 and C95: 6 characters (case insensitive);

  • for C99, C11 and C18: 31 characters (case sensitive);

  • for C++: 1024 characters (case sensitive).

The behavior service configuration with its associated -doc line can be used to specify the external identifier’s case significance and length and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.extidsig,behavior={c99, "^gcc[^/]*$",
   "case_insensitive&&63"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that external identifiers are case-insensitive and have a length significance of 63 characters.

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=STD.extidsig,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=STD.extidsig,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.extidsig,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.extidsig,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.extidsig,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify identifier significant case and length behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

an identifier’s case significance and length. Accepted forms are:

  • CASE&&INT_OR_NOLIMIT: an identifier’s case significance and length

CASE

accepted forms are:

  • case_sensitive: case distinctions are not ignored

  • case_insensitive: case distinctions are ignored

INT_OR_NOLIMIT

accepted forms are:

  • unlimited: no limit

  • NUM: limiting value


Rule STD.extinttp

Summary

Any extended integer types that exist in the implementation.

Description

Reports uses of non-standard integral types.

The behavior service configuration with its associated -doc line can be used to specify the non-standard integral types and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.extinttp,behavior={c99, "^gcc[^/]*$", "long long"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that non-standard integral type long long is supported.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.extinttp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify non-standard behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

implemented builtin types. Accepted forms are:

  • BUILTIN[;BUILTIN]*): the type kind is a BUILTIN

BUILTIN

accepted forms are:

  • _Bool: _Bool

  • __int128_t: __int128_t

  • __uint128_t: __uint128_t

  • bool: bool

  • char: char

  • char8_t: char8_t

  • char16_t: char16_t

  • char32_t: char32_t

  • double: double

  • float: float

  • half: half

  • int: int

  • long double: long double

  • long long: long long

  • long: long

  • short: short

  • signed char: signed char

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

  • void: void

  • wchar_t: wchar_t

  • nullptr_t: nullptr_t

  • short _Accum: short _Accum

  • _Accum: _Accum

  • long _Accum: long _Accum

  • unsigned short _Accum: unsigned short _Accum

  • unsigned _Accum: unsigned _Accum

  • unsigned long _Accum: unsigned long _Accum

  • short _Fract: short _Fract

  • _Fract: _Fract

  • long _Fract: long _Fract

  • unsigned short _Fract: unsigned short _Fract

  • unsigned _Fract: unsigned _Fract

  • unsigned long _Fract: unsigned long _Fract

  • _Sat short _Accum: _Sat short _Accum

  • _Sat _Accum: _Sat _Accum

  • _Sat long _Accum: _Sat long _Accum

  • _Sat unsigned short _Accum: _Sat unsigned short _Accum

  • _Sat unsigned _Accum: _Sat unsigned _Accum

  • _Sat unsigned long _Accum: _Sat unsigned long _Accum

  • _Sat short _Fract: _Sat short _Fract

  • _Sat _Fract: _Sat _Fract

  • _Sat long _Fract: _Sat long _Fract

  • _Sat unsigned short _Fract: _Sat unsigned short _Fract

  • _Sat unsigned _Fract: _Sat unsigned _Fract

  • _Sat unsigned long _Fract: _Sat unsigned long _Fract

  • UNSIZED_UNSIGNED_INTEGRAL: unsigned, unsized, integral built-in

  • UNSIZED_SIGNED_INTEGRAL: signed, unsized, integral built-in

  • FLOATING: floating point built-in

UNSIZED_UNSIGNED_INTEGRAL

accepted forms are:

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

UNSIZED_SIGNED_INTEGRAL

accepted forms are:

  • signed char: signed char

  • long long: long long

  • long: long

  • short: short

  • int: int

FLOATING

accepted forms are:

  • double: double

  • long double: long double

  • float: float

  • half: half


Rule STD.feraisex

Summary

Whether the feraiseexcept function raises the ``inexact’’ floating-point exception in addition to the ``overflow’’ or ``underflow’’ floating-point exception.

Description

Reports uses of the feraiseexcept function in <fenv.h> when it is relevant if it raises the inexact exception.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.feraisex,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all uses of feraiseexcept.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.feraisex,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.feraisex,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.feraisex,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.filebuff

Summary

The characteristics of file buffering.

Description

Reports uses of functions and macros in <stdio.h> when the characteristics of file buffering are not specified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.filebuff,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.filebuff,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.filebuff,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.filebuff,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.filemopn

Summary

Whether the same file can be simultaneously open multiple times.

Description

Reports uses of functions and macros in <stdio.h> when it is relevant if the same file can be open multiple times.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.filemopn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.filemopn,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.filemopn,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.filemopn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.fileposi

Summary

Whether the file position indicator of an append-mode stream is initially positioned at the beginning or end of the file.

Description

Reports uses of functions and macros in <stdio.h> when it is relevant if the file position indicator of an append mode stream is initially positioned at the beginning or end of the file.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fileposi,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.fileposi,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.fileposi,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.fileposi,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.fimename

Summary

The rules for composing valid file names.

Description

Reports uses of functions and macros in <stdio.h> when rules for composing valid file names are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fimename,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.fimename,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.fimename,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.fimename,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.flexaray

Summary

An incomplete array declaration in a record declaration.

Description

Reports incomplete array declarations in struct/union declarations.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.flexaray,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.flexaray,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.flexaray,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatcct

Summary

Whether and how floating expressions are contracted when not disallowed by the FP_CONTRACT pragma.

Description

Reports floating expressions when it is relevant if and how floating expressions are contracted when not disallowed by the #pragma FP_CONTRACT.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatcct,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.floatcct,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatcst

Summary

How the nearest representable value or the larger or smaller representable value immediately adjacent to the nearest representable value is chosen for certain floating constants.

Description

Reports floating-point literals whose representation is inexact when the representation is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatcst,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option statements
statements
-config=STD.floatcst,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.floatcst,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.floatcst,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatdem

Summary

Demotion of one real floating type to another produces a value outside the range that can be represented.

Description

Reports conversions from a floating point value to a floating point type that cannot represent it.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatdem,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.floatdem,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.floatdem,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatexc

Summary

Additional floating-point exceptions, rounding modes, environments, and classifications, and their macro names.

Description

Reports floating expressions when the additional floating-point exceptions, rounding modes, environments, and classifications, and their macro names are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatexc,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.floatexc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatiex

Summary

Whether the ``inexact’’ floating-point exception can be raised when the rounded result actually does equal the mathematical result in an IEC 60559 conformant implementation.

Description

Reports calls to functions in <math.h> when it is relevant if the inexact exception can be raised when the rounded result actually does equal the mathematical result.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatiex,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option macros
macros
-config=STD.floatiex,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.floatiex,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.floatiex,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatnrw

Summary

The direction of rounding when a floating-point number is converted to a narrower floating-point number.

Description

Reports conversions between two different floating-point types that changes value when direction of rounding is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatnrw,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported when it is not known if the value is preserved by the conversion.

Configuration

See generic service options.

Option casts
casts
-config=STD.floatnrw,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.floatnrw,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatrnd

Summary

The rounding behaviors characterized by non-standard values of FLT_ROUNDS.

Description

Reports floating expressions when the rounding behaviors characterized by non-standard values of FLT_ROUNDS are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatrnd,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.floatrnd,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatstd

Summary

The representations and sets of values of the various types of floating-point numbers.

Description

Reports floating expressions when the type representation is relevant.

The behavior service configuration with its associated -doc line can be used to specify the type representations of floating expressions and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatstd,behavior={c99, "^gcc[^/]*$", "float:ieee_single;double:ieee_quad;half"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that types float using single-precision IEEE floating-point format, double using quadruple-precision IEEE floating-point format and half are supported.

Note that, for this service, the report category is the reported floating point type.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.floatstd,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify implementation-defined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

floating-point types with their formats. Accepted forms are:

  • FLOAT[;FLOAT]*: the floating-point type with its format matches one of FLOAT

FLOAT

accepted forms are:

  • FLOAT_TYPE:FLOAT_FMT: the floating point type FLOAT_TYPE with format FLOAT_FMT

  • FLOAT_TYPE: the floating point type FLOAT_TYPE

FLOAT_TYPE

accepted forms are:

  • half: half

  • float: float

  • float128: float128

  • double: double

  • long double: long double

FLOAT_FMT

accepted forms are:

  • ieee_double: double-precision IEEE floating-point format

  • ieee_half: half-precision IEEE floating-point format

  • ieee_quad: quadruple-precision IEEE floating-point format

  • ieee_single: single-precision IEEE floating-point format

  • ppc_double_double: double-double implementation on PowerPC

  • x87_double_extended: x87 extended-precision floating-point format


Rule STD.floatunf

Summary

Whether the ``underflow’’ (and ``inexact’’) floating-point exception can be raised when a result is tiny but not inexact in an IEC 60559 conformant implementation.

Description

Reports calls to functions in <math.h> when it is relevant if the underflow (and inexact) floating-point exception can be raised when a result is tiny but not inexact.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatunf,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option macros
macros
-config=STD.floatunf,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.floatunf,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.floatunf,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.floatval

Summary

The accuracy of the floating-point operations and of the library functions in <math.h> and <complex.h> that return floating-point results.

Description

Reports floating expressions when the accuracy of the floating-point operations and of the library functions in <math.h> and <complex.h> that return floating-point results is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.floatval,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.floatval,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.fltevmth

Summary

The evaluation methods characterized by non-standard negative values of FLT_EVAL_METHOD.

Description

Reports floating expressions when the evaluation methods characterized by non-standard negative values of FLT_EVAL_METHOD are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fltevmth,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.fltevmth,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.fltevtyp

Summary

The types defined for float_t and double_t when the value of the FLT_EVAL_METHOD macro is less than 0 or greater than 2.

Description

Reports use of the types float_t and double_t when the value of FLT_EVAL_METHOD is less than 0 or greater than 2 is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fltevtyp,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for uses of types float_t and double_t.

Configuration

See generic service options.

Option types
types
-config=STD.fltevtyp,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.fltevtyp,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.fltevtyp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.fmodzero

Summary

Whether a domain error occurs or zero is returned when the fmod function has a second argument of zero.

Description

Reports uses of the fmod function in <math.h> with zero as second argument when it is relevant if a domain error occurs or zero is returned.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fmodzero,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

False negatives are present because there is no check that the conditions in the source code cover the function’s requirements.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.fmodzero,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.fntpqual

Summary

The specification of a function type includes any type qualifiers.

Description

Reports type qualifiers applied to a function type.

The behavior service configuration with its associated -doc line can be used to specify the diagnostic warning message for type qualifiers applied to a function type and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fntpqual,behavior={c99, "^gcc[^/]*$",
   "name(warn_typecheck_function_qualifiers_unspecified)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning warn_typecheck_function_qualifiers_unspecified is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.fntpqual,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.fntpqual,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.forhdecl

Summary

A declaration in first clause of a for statement.

Description

Reports declarations in the first clause of a for statement.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.forhdecl,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.forhdecl,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.forhdecl,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.forhdecl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.fprintfp

Summary

The output for %p conversion in the fprintf or fwprintf function.

Description

Reports uses of %p in the printf and fprintf functions in <stdio.h> when the format of its output is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fprintfp,behavior={c99, "^gcc[^/]*$", "std_print"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.fprintfp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify conversion behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

conversion identifiers. Accepted forms are:

  • ID[;ID]*: conversion identifier matches one of ID


Rule STD.fprscarg

Summary

The format for the fprintf or fscanf function does not match the argument list.

Description

Reports a variadic formatted input/output function that has a formatted argument that does not match the corresponding format specification.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fprscarg,behavior={c99, "^gcc[^/]*$", "FMT_a"}

indicates that for the format specification with formatting identifier FMT_a the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …). The variadic_fmt global configuration can be used to define the formatting identifier for matching function calls with the expected specifiers and argument types. For example:

-variadic_fmt={FMT_a, "name(printf)",
               {{"^%(la)", {{"^la$", "type(canonical(builtin(int)))"}}}}}

indicates that the formatting identifier FMT_a allows a call to the function printf where the formatting argument has a specifier matching ^%(la) with the corresponding argument of type int.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.fprscarg,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify conversion behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

conversion identifiers. Accepted forms are:

  • ID[;ID]*: conversion identifier matches one of ID


Rule STD.fprscfmt

Summary

An invalid conversion specification is found in the format for one of the formatted input/output functions, or the strftime or wcsftime function.

Description

Reports invalid conversion specifications in the format for one of the formatted input/output functions or the strftime or wcsftime functions.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fprscfmt,behavior={c99, "^gcc[^/]*$", "FMT_a"}

indicates that for the format specification with formatting identifier FMT_a the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …). The variadic_fmt global configuration can be used to define the formatting identifier for matching function calls with additional specifiers and argument types. For example:

-variadic_fmt={FMT_a, "name(printf)",
               {{"^%(la)", {{"^la$", "type(canonical(builtin(int)))"}}}}}

indicates that the formatting identifier FMT_a allows a call to the function printf where the formatting argument has a specifier matching ^%(la) with the corresponding argument of type int.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.fprscfmt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify conversion behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

conversion identifiers. Accepted forms are:

  • ID[;ID]*: conversion identifier matches one of ID


Rule STD.freesten

Summary

The effect of program termination in a freestanding environment.

Description

Reports uses of a freestanding environment when the effect of program termination is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.freesten,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all freestanding environments.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.freesten,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.freestlb

Summary

Any library facilities available to a freestanding program, other than the minimal set required.

Description

Reports uses of libraries that are not supported in a freestanding program.

The behavior service configuration with its associated -doc line can be used to specify the libraries that are not supported in a freestanding program and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.freestlb,behavior={c99, "^gcc[^/]*$", "env(core);^setjmp\\.h$"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that libraries in the core environment and the header setjmp.h are supported in a freestanding program.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.freestlb,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

headers available in a freestanding environment. Accepted forms are:

  • ENV[;ENV]*: the header matches one of ENV

ENV

accepted forms are:

  • env(core): core environment

  • ^REGEX$: the file name matches ^REGEX$

  • name(ID): the file name is ID

REGEX

accepted forms are:


Option macros
macros
-config=STD.freestlb,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.freestlb,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.freestnd

Summary

The name and type of the function called at program startup in a freestanding environment.

Description

Reports uses of a freestanding environment when the name or type of the function called at program startup is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.freestnd,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all freestanding environments.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.freestnd,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence for the standard and compiler.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior for the environment is specified


Rule STD.fscanfms

Summary

The interpretation of a - character that is neither the first nor the last character, nor the second where a ^ character is the first, in the scanlist for %[ conversion in the fscanf or fwscanf function.

Description

Reports uses of %[ in the scanf and fscanf functions in <stdio.h> when the interpretation of a - character that is neither the first nor the last character in the scanlist is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fscanfms,behavior={c99, "^gcc[^/]*$", "std_scan"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.fscanfms,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify conversion behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

conversion identifiers. Accepted forms are:

  • ID[;ID]*: conversion identifier matches one of ID


Rule STD.fscanfp

Summary

The set of sequences matched by a %p conversion and the interpretation of the corresponding input item in the fscanf or fwscanf function.

Description

Reports uses of %p in the scanf and fscanf functions in <stdio.h> when the format of its input is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.fscanfp,behavior={c99, "^gcc[^/]*$", "std_scan"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.fscanfp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify conversion behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

conversion identifiers. Accepted forms are:

  • ID[;ID]*: conversion identifier matches one of ID


Rule STD.funcbind

Summary

use of deprecated features in header functional.

Description

Use of deprecated types and members in the header functional.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.funcbind,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.funcbind,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.funcbind,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.funcbind,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.funojptr

Summary

A pointer to a function is cast to a pointer to an object or a pointer to an object is cast to a pointer to a function.

Description

Reports explicit casts from a function pointer to an object pointer or from an object pointer to a function pointer.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.funojptr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.funojptr,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.funojptr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.funptrcv

Summary

A pointer is used to call a function whose type is not compatible with the pointed-to type.

Description

Reports uses of a pointer to call a function whose type is not compatible with the original type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.funptrcv,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.funptrcv,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.funptrcv,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.getenvfn

Summary

The set of environment names and the method for altering the environment list used by the getenv function.

Description

Reports uses of the getenv function in <stdlib.h> when the set of environment names and the method for altering the environment list is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.getenvfn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all calls to getenv.

Configuration

See generic service options.

Option macros
macros
-config=STD.getenvfn,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.getenvfn,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.getenvfn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.hdrexpnd

Summary

The #include preprocessing directive that results after expansion does not match one of the two header name forms.

Description

Reports #include preprocessing directives that do not match one of the two header name forms.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.hdrexpnd,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.hdrexpnd,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.hostmain

Summary

A program in a hosted environment does not define a function named main using one of the specified forms.

Description

Reports programs in a hosted environment that do not define a function named main using one of the specified forms.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for programs in a hosted environment and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.hostmain,behavior={c99, "^gcc[^/]*$",
   "name(warn_main_redefined)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning warn_main_redefined is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.hostmain,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.hostmain,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.iddiflkg

Summary

The same identifier has both internal and external linkage in the same translation unit.

Description

Reports definitions with both internal and external linkage.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.iddiflkg,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.iddiflkg,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.iddiflkg,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.iddollar

Summary

A dollar character in an identifier.

Description

Reports uses of $ in an identifier name.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.iddollar,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=STD.iddollar,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=STD.iddollar,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=STD.iddollar,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=STD.iddollar,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=STD.iddollar,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.iddollar,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=STD.iddollar,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option behavior
behavior
-config=STD.iddollar,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.impldefn

Summary

use of deprecated defaulted implicit definitions of copy constructors and copy assignment operators.

Description

Reports any use of an implicit definition as defaulted of:

  • a copy constructor for a class that has a user-declared copy assignment operator or a user-declared destructor; or

  • a copy assignment operator for a class that has a user-declared copy constructor or a user-declared destructor.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.impldefn,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option calls
calls
-config=STD.impldefn,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=STD.impldefn,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.impldefn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.implfunc

Summary

An implicit function declaration.

Description

Reports implicit function declarations.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.implfunc,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.implfunc,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.implfunc,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.implfunc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.inclangl

Summary

The places that are searched for an included < > delimited header, and how the places are specified or the header is identified.

Description

Reports #include directives with a name in angle brackets when the method for locating files is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.inclangl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all #include directives using angle brackets.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.inclangl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.inclexpd

Summary

The method by which preprocessing tokens (possibly resulting from macro expansion) in a #include directive are combined into a header name.

Description

Reports #include directives with expanded names when the method by which preprocessing tokens are combined into a header name is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.inclexpd,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all #include directives with expanded names.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.inclexpd,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.inclfile

Summary

How the named source file is searched for in an included " " delimited header.

Description

Reports #include directives with a name in quotes when the method for locating file is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.inclfile,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all #include directives using quoted names.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.inclfile,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.inclhead

Summary

How sequences in both forms of header names are mapped to headers or external source file names.

Description

Reports #include directives when the mapping from header name to file name is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.inclhead,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all #include directives.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.inclhead,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.inclnest

Summary

Nesting levels for #include files.

Description

Reports infringements of the limit for nesting levels for #include files.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of nesting levels for #include files and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.inclnest,behavior={c99, "^gcc[^/]*$", "15"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of nesting levels for #include files is 15.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.inclnest,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.inclnest,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.indxcnst

Summary

A const-qualified array index.

Description

Reports const qualified array indices.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.indxcnst,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option types
types
-config=STD.indxcnst,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.indxcnst,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.indxcnst,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.indxvltl

Summary

A volatile-qualified array index.

Description

Reports volatile qualified array indices.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.indxvltl,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option types
types
-config=STD.indxvltl,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.indxvltl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.indxvltl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.intconvn

Summary

Conversion to or from an integer type produces a value outside the range that can be represented.

Description

Reports conversions between floating point and integral types that produces a value that cannot be represented.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.intconvn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.intconvn,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.intconvn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.intfloat

Summary

The direction of rounding when an integral number is converted to a floating-point number that cannot exactly represent the original value.

Description

Reports conversions from an integer to a floating-point type when the direction of rounding is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.intfloat,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported when it is not known if the value is preserved by the conversion.

Configuration

See generic service options.

Option casts
casts
-config=STD.intfloat,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.intfloat,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.intnlobj

Summary

An identifier for an object with internal linkage and an incomplete type is declared with a tentative definition.

Description

Reports objects with internal linkage and an incomplete type declared with a tentative definition.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.intnlobj,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.intnlobj,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.intnlobj,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.intrpntr

Summary

The result of converting a pointer to an integer or vice versa.

Description

Reports casts from a pointer to an integer or an integer to a pointer when its result is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.intrpntr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.intrpntr,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.intrpntr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.intvdevc

Summary

What constitutes an interactive device.

Description

Reports if the definition of an interactive device is unspecified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.intvdevc,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.intvdevc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ipconrep

Summary

The result of a conversion by one of the formatted input functions cannot be represented in the corresponding object, or the receiving object does not have an appropriate type.

Description

Reports uses of formatted input functions where the conversion result cannot be represented in the corresponding object, or the receiving object does not have an appropriate type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ipconrep,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.ipconrep,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Option calls
calls
-config=STD.ipconrep,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option contexts
contexts
-config=STD.ipconrep,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule STD.itertype

Summary

Use of deprecated types from header iterator.

Description

Reports use of deprecated types from header iterator.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.itertype,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.itertype,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.itertype,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.itertype,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.linedir

Summary

The #line preprocessing directive that results after expansion does not match one of the two well-defined forms, or its digit sequence specifies zero or a number greater than 2147483647.

Description

Reports #line directives that do not match one of the two well-defined forms.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for #line directives and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.linedir,behavior={c99, "^gcc[^/]*$",
   "name(ext_pp_line_zero)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning ext_pp_line_zero is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.linedir,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.linedir,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.ltrlbin

Summary

An integer literal with prefix 0b.

Description

Reports integer literals with prefix 0b.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ltrlbin,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option literals
literals
-config=STD.ltrlbin,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Option behavior
behavior
-config=STD.ltrlbin,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ltrlhxfl

Summary

A hexadecimal floating-point literal.

Description

Reports hexadecimal floating-point literals.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.ltrlhxfl,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option literals
literals
-config=STD.ltrlhxfl,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Option behavior
behavior
-config=STD.ltrlhxfl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ltrllnln

Summary

An integer literal having one of the long long types.

Description

Reports integer literals having one of the long long types.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.ltrllnln,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option literals
literals
-config=STD.ltrllnln,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Option behavior
behavior
-config=STD.ltrllnln,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.macident

Summary

Macro identifiers simultaneously defined in one preprocessing translation unit.

Description

Reports infringements of the limit for macro identifiers simultaneously defined in a single preprocessing translation unit.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of macro identifiers in a single preprocessing translation unit and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.macident,behavior={c99, "^gcc[^/]*$", "4095"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of macro identifiers in a single preprocessing translation unit is 495.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.macident,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.macident,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.macrsynt

Summary

An object macro not separated from its body by white-space.

Description

Reports definitions of an object macro not separated from its body by white-space.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.macrsynt,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.macrsynt,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.macrsynt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.macrvarg

Summary

A macro defined with a variable number of arguments.

Description

Reports definitions of macros with a variable number of arguments.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.macrvarg,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.macrvarg,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.macrvarg,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.mainargv

Summary

The values given to the strings pointed to by the argv argument to main.

Description

Reports the definition of the main function when the values given to the strings pointed to by the argv argument are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.mainargv,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for any main function definition with arguments.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.mainargv,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.maindefn

Summary

An alternative manner in which the main function may be defined.

Description

Reports the definition of the main function having a non-standard form.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.maindefn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for any main function definition with arguments.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.maindefn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.mainrtrn

Summary

The termination status returned to the hosted environment if the return type of main is not compatible with int.

Description

Reports the definition of the main function if the return type is not compatible with int.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for the main function when the return type is not compatible with int and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.mainrtrn,behavior={c99, "^gcc[^/]*$",
   "name(ext_main_returns_nonint)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning ext_main_returns_nonint is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.mainrtrn,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.mainrtrn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.mathdmer

Summary

The values returned by the mathematics functions on domain errors.

Description

Reports uses of functions in <math.h> that have restricted input domains when the values returned on domain error is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.mathdmer,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

False negatives are present because there is no check if the conditions in the source code cover the function’s requirements.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.mathdmer,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.mathrner

Summary

The values returned by the mathematics functions on underflow range errors, whether errno is set to the value of the macro ERANGE when the integer expression math_errhandling & MATH_ERRNO is nonzero, and whether the ``underflow’’ floating-point exception is raised when the integer expression math_errhandling & MATH_ERREXCEPT is nonzero.

Description

Reports uses of functions in <math.h> when underflow error behavior is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.mathrner,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all calls to functions in <math.h>.

Configuration

See generic service options.

Option macros
macros
-config=STD.mathrner,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.mathrner,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.mathrner,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.mathrond

Summary

Whether the functions in <math.h> honor the rounding direction mode in an IEC 60559 conformant implementation.

Description

Reports uses of functions in <math.h> when rounding direction mode is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.mathrond,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all calls to functions in <math.h>.

Configuration

See generic service options.

Option macros
macros
-config=STD.mathrond,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.mathrond,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.mathrond,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.membrecd

Summary

Members in a single structure or union.

Description

Reports infringements of the limit for members in a single struct/union.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of members in a struct/union and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.membrecd,behavior={c99, "^gcc[^/]*$", "1023"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of members in a struct/union is 1023.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.membrecd,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.membrecd,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.metatype

Summary

Use of deprecated types from header type_traits.

Description

Reports use of deprecated types from header type_traits.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.metatype,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.metatype,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.metatype,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.metatype,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.multbchr

Summary

The mapping between physical source file multibyte characters and the source character set in translation phase 1.

Description

Reports multibyte characters when the mapping to source character set in translation phase 1 is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.multbchr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.multbchr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.multbtid

Summary

Which additional multibyte characters may appear in identifiers and their correspondence to universal character names.

Description

Reports multibyte characters in an identifier when their correspondence to universal character names is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.multbtid,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for any multibyte characters in an identifier.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.multbtid,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.multbtsl

Summary

The value of a string literal containing a multibyte character or escape sequence not represented in the execution character set.

Description

Reports multibyte or escape characters in a string literal when its value is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.multbtsl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for multibyte or escape characters in a string literal.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.multbtsl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ncstinit

Summary

A non-constant initializer for array or structure.

Description

Reports non-constant initializers for array/struct.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.ncstinit,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.ncstinit,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.negshift

Summary

An expression is shifted by a negative number or by an amount greater than or equal to the width of the promoted expression.

Description

Reports shift operators on an expression whose second operand is out of its allowed range.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for shift operators and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.negshift,behavior={c99, "^gcc[^/]*$",
   "name(warn_shift_negative)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning warn_shift_negative is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.negshift,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.negshift,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.nexidsig

Summary

The number of significant initial characters in a non-external identifier.

Description

Reports distinct non-external identifiers that are considered the same by the toolchain according to length significance. Note that the standard limits for non-external identifiers are:

  • for C90 and C95: 31 characters;

  • for C99, C11 and C18: 63 characters;

  • for C++: 1024 characters.

The behavior service configuration with its associated -doc line can be used to specify the non-external identifier’s case significance and length and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.nexidsig,behavior={c99, "^gcc[^/]*$",
   "case_insensitive&&unlimited"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that non-external identifiers are case-insensitive and have an unlimited length significance.

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=STD.nexidsig,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=STD.nexidsig,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.nexidsig,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.nexidsig,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.nexidsig,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify identifier significant case and length behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

an identifier’s case significance and length. Accepted forms are:

  • CASE&&INT_OR_NOLIMIT: an identifier’s case significance and length

CASE

accepted forms are:

  • case_sensitive: case distinctions are not ignored

  • case_insensitive: case distinctions are ignored

INT_OR_NOLIMIT

accepted forms are:

  • unlimited: no limit

  • NUM: limiting value


Rule STD.nodecltr

Summary

A bare structure/union/enumeration definition inside a structure/union definition.

Description

Reports a bare struct/union/enum definition inside a struct/union definition.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.nodecltr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.nodecltr,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.nodecltr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.nonstdc

Summary

A non-STDC #pragma preprocessing directive that is documented as causing translation failure or some other form of undefined behavior is encountered.

Description

Reports a non-STDC #pragma directive causing translation failure.

The behavior service configuration with its associated -doc line can be used to specify the non-STDC #pragma directive and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.nonstdc,behavior={c99, "^gcc[^/]*$", "^GCC.*$"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the non-STDC #pragma directive that matches ^GCC.*$ is supported.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.nonstdc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a -name_selector identifier or a matcher expression that matches the body of the #pragma.


Rule STD.nullchar

Summary

The number of null characters that may be appended to data written to a binary stream.

Description

Reports uses of functions and macros in <stdio.h> when the number of null characters that may be appended to data written to a binary stream is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.nullchar,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.nullchar,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.nullchar,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.nullchar,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.nullpntr

Summary

The null pointer constant to which the macro NULL expands.

Description

Reports uses of the NULL macro when its content is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.nullpntr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.nullpntr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.objbytes

Summary

The number, order, and encoding of bytes in any object.

Description

Reports if the number, order and encoding of bytes in an object is unspecified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.objbytes,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.objbytes,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.paramfun

Summary

Parameters in one function definition.

Description

Reports infringements of the limit for parameters in one function definition.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of parameters in a function definition and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.paramfun,behavior={c99, "^gcc[^/]*$", "127"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of parameters in a function definition is 127.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.paramfun,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.paramfun,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.parammac

Summary

Parameters in one macro definition.

Description

Reports infringements of the limit for parameters in one macro definition.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of parameters in a macro definition and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.parammac,behavior={c99, "^gcc[^/]*$", "127"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of parameters in a macro definition is 127.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.parammac,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.parammac,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.pexpnest

Summary

Nesting levels of parenthesized expressions within a full expression.

Description

Reports infringements of the limit for nesting levels of parenthesized expressions within a full expression.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of nesting levels of parenthesized expressions and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.pexpnest,behavior={c99, "^gcc[^/]*$", "63"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of nesting levels of parenthesized expressions is 63.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.pexpnest,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.pexpnest,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.plainbit

Summary

Whether a ``plain’’ int bit-field is treated as a signed int bit-field or as an unsigned int bit-field.

Description

Reports definitions of plain int bit-fields when the signedness is relevant.

The behavior service configuration with its associated -doc line can be used to specify the signedness of plain int bit-fields and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.plainbit,behavior={c99, "^gcc[^/]*$", "signed"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that plain int bit-fields are signed.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.plainbit,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=STD.plainbit,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option behavior
behavior
-config=STD.plainbit,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify implementation-defined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

whether a plain int is signed or unsigned. Accepted values are:

  • signed: a plain int is signed;

  • unsigned: a plain int is unsigned;


Rule STD.planchar

Summary

Which of signed char or unsigned char has the same range, representation, and behavior as ``plain’’ char.

Description

Reports uses of plain char type when the signedness is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.planchar,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option types
types
-config=STD.planchar,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.planchar,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option statements
statements
-config=STD.planchar,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.planchar,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.planchar,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ppcomma

Summary

A comma operator in a preprocessor conditional.

Description

Reports comma operators in a preprocessor conditional.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ppcomma,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.ppcomma,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ppifnest

Summary

Nesting levels of conditional inclusion.

Description

Reports infringements of the limit for nesting levels of conditional inclusion.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of nesting levels of conditional inclusion and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ppifnest,behavior={c99, "^gcc[^/]*$", "63"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of nesting levels of conditional inclusion is 63.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.ppifnest,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.ppifnest,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.pragmdir

Summary

The behavior on each recognized #pragma directive.

Description

Reports #pragma directives.

The behavior service configuration with its associated -doc line can be used to specify the #pragma directives and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.pragmdir,behavior={c99, "^gcc[^/]*$", "^(warning|once)$"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that #pragma directives matching ^(warning|once) are supported.

Note that, for this service, the report category is the pragma name; for STDC pragmas, the category is the first word after STDC.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.pragmdir,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a -name_selector identifier or a matcher expression that matches the body of the #pragma.


Rule STD.pragmfpc

Summary

The default state for the FP_CONTRACT pragma.

Description

Reports floating expressions when the default state for #pragma FP_CONTRACT is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.pragmfpc,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.pragmfpc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.pragmfva

Summary

The default state for the FENV_ACCESS pragma.

Description

Reports floating expressions when the default state for #pragma FENV_ACCESS is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.pragmfva,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all floating expressions.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.pragmfva,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.pragmhdr

Summary

The locations within #pragma directives where header name preprocessing directives are recognised.

Description

Reports delimited header names in a #pragma directive when the locations where they are recognised are relevant.

The behavior service configuration with its associated -doc line can be used to specify #pragma directives and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.pragmhdr,behavior={c99, "^gcc[^/]*$", "any()"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the expected behavior is specified for all delimited header names in any #pragma directive.

Imprecision

Cautions are reported for all delimited header names in a #pragma directives.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.pragmhdr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a -name_selector identifier or a matcher expression that matches the body of the #pragma.


Rule STD.prepdirc

Summary

The behavior for each non-standard preprocessing directive.

Description

Reports errors in the preprocessing directives even when excluded by conditional compilation.

The behavior service configuration with its associated -doc line can be used to specify the behavior of the preprocessing directives and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.prepdirc,behavior={c99, "^gcc[^/]*$", "^(warning|unassert)$"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the preprocessing directives that match ^(warning|unassert)$ are supported.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=STD.prepdirc,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=STD.prepdirc,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=STD.prepdirc,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Option behavior
behavior
-config=STD.prepdirc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a -name_selector identifier or a matcher expression used to select the directives.


Rule STD.pteincmp

Summary

A pointer is implicitly converted to another pointer with an incompatible pointee type.

Description

Reports implicit conversions from a pointer to another pointer with incompatible pointee types unless:

  • the conversion is between an object pointer and a void pointer

  • the source expression is a null pointer.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.pteincmp,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.pteincmp,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.pteincmp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ptrdifft

Summary

The size of the result of subtracting two pointers to elements of the same array.

Description

Reports uses of ptrdiff_t if the underlying type is unspecified or incongruent.

The behavior service configuration with its associated -doc line can be used to specify the underlying type of ptrdiff_t and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ptrdifft,behavior={c99, "^gcc[^/]*$", "unsigned long"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that ptrdiff_t is unsigned long.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.ptrdifft,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.ptrdifft,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify implementation-defined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • _Bool: _Bool

  • __int128_t: __int128_t

  • __uint128_t: __uint128_t

  • bool: bool

  • char: char

  • char8_t: char8_t

  • char16_t: char16_t

  • char32_t: char32_t

  • int: int

  • long long: long long

  • long: long

  • short: short

  • signed char: signed char

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

  • wchar_t: wchar_t


Rule STD.ptrintcv

Summary

Conversion of a pointer to an integer type produces a value outside the range that can be represented.

Description

Reports conversions of a pointer to an integer type that produces a value that cannot be represented.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ptrintcv,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.ptrintcv,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.ptrintcv,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ptrnconv

Summary

A pointer is converted to other than an integral or pointer type.

Description

Reports conversions from a pointer to a type other than an integral or pointer type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ptrnconv,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.ptrnconv,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.ptrnconv,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.ptypnest

Summary

Nesting levels of parenthesized declarators within a full declarator.

Description

Reports infringements of the limit for nesting levels of parenthesized declarators within a full declarator.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of nesting levels of parenthesized declarators and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.ptypnest,behavior={c99, "^gcc[^/]*$", "63"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of nesting levels of parenthesized declarators is 63.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.ptypnest,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.ptypnest,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.qotemtch

Summary

An unmatched ' or " character is encountered on a logical source line during tokenization.

Description

Reports unmatched single or double quote characters that are encountered during tokenization.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for unmatched single or double quote characters and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.qotemtch,behavior={c99, "^gcc[^/]*$",
   "name(ext_unterminated_char_or_string)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning ext_unterminated_char_or_string is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.qotemtch,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.qotemtch,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.qsortord

Summary

The order of two elements that compare as equal in an array sorted by the qsort function.

Description

Reports uses of the qsort function in <stdlib.h> when order of elements that compare as equal is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.qsortord,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.qsortord,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.qsortord,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.qsortord,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.recdnest

Summary

Levels of nested structure or union definitions in a single struct-declaration-list.

Description

Reports infringements of the limit for levels of nested struct/union definitions in a single struct-declaration-list.

The behavior service configuration with its associated -doc line can be used to specify the maximum number of nested struct/union definitions and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.recdnest,behavior={c99, "^gcc[^/]*$", "15"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the maximum number of nested struct/union definitions is 15.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.recdnest,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

limiting value or ‘std’. Accepted forms are:

  • std: use the standard’s limit

  • unlimited: no limit

  • NUM: limiting value


Option declarations
declarations
-config=STD.recdnest,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.redltype

Summary

A redeclared typedef.

Description

Reports typedef redeclarations.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.redltype,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.redltype,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.redltype,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.register

Summary

The extent to which suggestions made by using the register storage-class specifier are effective.

Description

Reports uses of the register storage class when the extent of the effectiveness of the related suggestion is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.register,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.register,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Option declarations
declarations
-config=STD.register,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.removefl

Summary

The effect of the remove function on an open file.

Description

Reports uses of the remove function in <stdio.h> when the effect on an open file is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.removefl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.removefl,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.removefl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.removefl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.remquofn

Summary

The base-2 logarithm of the modulus used by the remquo functions in reducing the quotient.

Description

Reports uses of the remquo function in <math.h> when the base-2 logarithm of the modulus used to reduce the quotient is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.remquofn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all calls to remquo.

Configuration

See generic service options.

Option macros
macros
-config=STD.remquofn,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.remquofn,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.remquofn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.renamefl

Summary

The effect if a file with the new name exists prior to a call to the rename function.

Description

Reports uses of the rename function in <stdio.h> when the effect on an already existing destination file is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.renamefl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.renamefl,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.renamefl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.renamefl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.rtrnemty

Summary

An empty return statement in a function with a non-void return type.

Description

Reports empty return statements in a function with a non-void return type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.rtrnemty,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.rtrnemty,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.rtrnemty,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.rtrnemty,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.rtsigned

Summary

The result of a right shift of a negative-valued signed integral type.

Description

Reports right shift operators on negative values when the result of the shift is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.rtsigned,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.rtsigned,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.rtsigned,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.rtsigned,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.rvalsubs

Summary

A non-lvalue array subscript.

Description

Reports non-lvalue array subscripting.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.rvalsubs,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.rvalsubs,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.rvalsubs,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.setlocle

Summary

Strings other than “C” and “” that may be passed as the second argument to the setlocale function.

Description

Reports uses of the setlocale function in <locale.h> when the strings that may be passed as the second argument are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.setlocle,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all calls to setlocale.

Configuration

See generic service options.

Option macros
macros
-config=STD.setlocle,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.setlocle,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.setlocle,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.shortsgn

Summary

The result of, or the signal raised by, converting an integer to a signed integer type when the value cannot be represented in an object of that type.

Description

Reports conversions from an integer to a shorter integer type when the resulting value is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.shortsgn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.shortsgn,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.shortsgn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.signalbk

Summary

Whether the equivalent of signal(sig, SIG_DFL); is executed prior to the call of a signal handler, and, if not, the blocking of signals that is performed.

Description

Reports uses of the signal functions in <signal.h> when it is relevant if the signal is blocked prior to the call of a signal handler.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.signalbk,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.signalbk,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.signalbk,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.signalbk,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.signalfn

Summary

Signal values other than SIGFPE, SIGILL, and SIGSEGV that correspond to a computational exception.

Description

Reports uses of the signal functions in <signal.h> when it is relevant if values other than SIGFPE, SIGILL, and SIGSEGV correspond to a computational exception.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.signalfn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.signalfn,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.signalfn,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.signalfn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.signalsl

Summary

Whether the default handling is reset if the SIGILL signal is received by a handler specified to the signal function.

Description

Reports uses of the signal functions in <signal.h> when it is relevant if the default handling is reset after receiving the SIGILL signal.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.signalsl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.signalsl,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.signalsl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.signalsl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.signalsm

Summary

The set of signals, their semantics, and their default handling.

Description

Reports uses of the signal function in <signal.h>.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.signalsm,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.signalsm,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.signalsm,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.signalsm,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.signalst

Summary

Signals for which the equivalent of signal(sig, SIG_IGN); is executed at program startup.

Description

Reports uses of the signal function in <signal.h> when the default handling is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.signalst,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.signalst,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.signalst,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.signalst,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.signdint

Summary

Whether signed integer types are represented using sign and magnitude, two’s complement, or one’s complement, and whether the extraordinary value is a trap representation or an ordinary value.

Description

Reports if the representations of signed integers is unspecified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.signdint,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.signdint,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.sizettyp

Summary

The value of the result of the sizeof operator.

Description

Reports uses of size_t if the underlying type is unspecified or incongruent.

The behavior service configuration with its associated -doc line can be used to specify the underlying type of size_t and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.sizettyp,behavior={c99, "^gcc[^/]*$", "unsigned long"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that size_t is unsigned long.

Configuration

See generic service options.

Option declarations
declarations
-config=STD.sizettyp,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.sizettyp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify implementation-defined behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • _Bool: _Bool

  • __int128_t: __int128_t

  • __uint128_t: __uint128_t

  • bool: bool

  • char: char

  • char8_t: char8_t

  • char16_t: char16_t

  • char32_t: char32_t

  • int: int

  • long long: long long

  • long: long

  • short: short

  • signed char: signed char

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

  • wchar_t: wchar_t


Rule STD.spacechr

Summary

Whether space characters that are written out to a text stream immediately before a new-line character appear when read in.

Description

Reports uses of functions and macros in <stdio.h> when it is relevant if space characters that are written out to a text stream immediately before a new-line character appear when read in.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.spacechr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.spacechr,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=STD.spacechr,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.spacechr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.spunique

Summary

use of shared_ptr observers.

Description

Reports use of shared_ptr observers.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.spunique,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option statements
statements
-config=STD.spunique,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.spunique,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.spunique,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.stdcctxt

Summary

The CX_LIMITED_RANGE, FENV_ACCESS, or FP_CONTRACT pragma is used in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement.

Description

Reports uses of #pragma STDC CX_LIMITED_RANGE, FENV_ACCESS, and FP_CONTRACT in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.stdcctxt,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.stdcctxt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.stdcprag

Summary

A #pragma STDC preprocessing directive does not match one of the well-defined forms.

Description

Reports #pragma STDC directives that do not match one of the specified forms.

The behavior service configuration with its associated -doc line can be used to specify diagnostic warning messages for #pragma STDC directives and its documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.stdcprag,behavior={c99, "^gcc[^/]*$",
   "name(ext_on_off_switch_syntax)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), the behavior in the presence of the diagnostic warning ext_on_off_switch_syntax is understood.

Note that, for this service, the report category is the diagnostic identifier.

Configuration

See generic service options.

Option diagnostics
diagnostics
-config=STD.stdcprag,diagnostics={TAGS, DIAG_TAG},...

Assigns report tags to the parser diagnostics.

The configuration’s content is a list of clauses specifying the diagnostics and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIAG_TAG:

a -name_selector identifier or a matcher expression used to select the diagnostics. Accepted forms are:

  • ^REGEX$: the name matches ^REGEX$

  • !NAME_MATCHER: the name does not match NAME_MATCHER

  • TEXT: the name is TEXT


Option behavior
behavior
-config=STD.stdcprag,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a diagnostic whose name matches NAME_MATCHER (see the -name_selector global configuration).


Rule STD.stdmacro

Summary

The values or expressions assigned to the macros specified in the headers <float.h>, <limits.h>, and <stdint.h>.

Description

Reports uses of the macros specified in <float.h>, <limits.h> and <stdint.h> when their value is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.stdmacro,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all use of macros specified in <float.h>, <limits.h> and <stdint.h>.

Configuration

See generic service options.

Option macros
macros
-config=STD.stdmacro,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option behavior
behavior
-config=STD.stdmacro,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Option declarations
declarations
-config=STD.stdmacro,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule STD.stdtypes

Summary

Non-standard builtin types.

Description

Reports uses of non-standard types.

The behavior service configuration with its associated -doc line can be used to specify the non-standard integral types and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.stdtypes,behavior={c99, "^gcc[^/]*$", "long long"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that non-standard integral type long long is supported.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.stdtypes,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify non-standard behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

implemented builtin types. Accepted forms are:

  • BUILTIN[;BUILTIN]*): the type kind is a BUILTIN

BUILTIN

accepted forms are:

  • _Bool: _Bool

  • __int128_t: __int128_t

  • __uint128_t: __uint128_t

  • bool: bool

  • char: char

  • char8_t: char8_t

  • char16_t: char16_t

  • char32_t: char32_t

  • double: double

  • float: float

  • half: half

  • int: int

  • long double: long double

  • long long: long long

  • long: long

  • short: short

  • signed char: signed char

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

  • void: void

  • wchar_t: wchar_t

  • nullptr_t: nullptr_t

  • short _Accum: short _Accum

  • _Accum: _Accum

  • long _Accum: long _Accum

  • unsigned short _Accum: unsigned short _Accum

  • unsigned _Accum: unsigned _Accum

  • unsigned long _Accum: unsigned long _Accum

  • short _Fract: short _Fract

  • _Fract: _Fract

  • long _Fract: long _Fract

  • unsigned short _Fract: unsigned short _Fract

  • unsigned _Fract: unsigned _Fract

  • unsigned long _Fract: unsigned long _Fract

  • _Sat short _Accum: _Sat short _Accum

  • _Sat _Accum: _Sat _Accum

  • _Sat long _Accum: _Sat long _Accum

  • _Sat unsigned short _Accum: _Sat unsigned short _Accum

  • _Sat unsigned _Accum: _Sat unsigned _Accum

  • _Sat unsigned long _Accum: _Sat unsigned long _Accum

  • _Sat short _Fract: _Sat short _Fract

  • _Sat _Fract: _Sat _Fract

  • _Sat long _Fract: _Sat long _Fract

  • _Sat unsigned short _Fract: _Sat unsigned short _Fract

  • _Sat unsigned _Fract: _Sat unsigned _Fract

  • _Sat unsigned long _Fract: _Sat unsigned long _Fract

  • UNSIZED_UNSIGNED_INTEGRAL: unsigned, unsized, integral built-in

  • UNSIZED_SIGNED_INTEGRAL: signed, unsized, integral built-in

  • FLOATING: floating point built-in

UNSIZED_UNSIGNED_INTEGRAL

accepted forms are:

  • unsigned char: unsigned char

  • unsigned long long: unsigned long long

  • unsigned long: unsigned long

  • unsigned short: unsigned short

  • unsigned: unsigned

UNSIZED_SIGNED_INTEGRAL

accepted forms are:

  • signed char: signed char

  • long long: long long

  • long: long

  • short: short

  • int: int

FLOATING

accepted forms are:

  • double: double

  • long double: long double

  • float: float

  • half: half


Rule STD.stmtexpr

Summary

A GNU statement expression.

Description

Reports GNU statement expressions.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.stmtexpr,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option statements
statements
-config=STD.stmtexpr,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.stmtexpr,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.stmtexpr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.storgitr

Summary

Use of deprecated class types from header memory.

Description

Reports use of deprecated class types from header memory.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.storgitr,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.storgitr,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.storgitr,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.storgitr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.strerror

Summary

The contents of the error message strings returned by the strerror function.

Description

Reports uses of the strerror function in <string.h> when the contents of the error message strings returned is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.strerror,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.strerror,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.strerror,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.strerror,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.strincmp

Summary

An implicit conversion of a string literal removes the const qualifier.

Description

Reports implicit conversions that remove the const qualifier from a string literal type

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C++11 standard ..."
-config=STD.strincmp,behavior={"c++11", "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C++11 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option casts
casts
-config=STD.strincmp,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Option behavior
behavior
-config=STD.strincmp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.stringfy

Summary

Whether the # operator inserts a \ character before the \ character that begins a universal character name in a character constant or string literal.

Description

Reports uses of the stringification #operator when it is relevant if it inserts a \ character before the \ character that begins a universal character name.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.stringfy,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all uses of the stringification #operator.

Configuration

See generic service options.

Option behavior
behavior
-config=STD.stringfy,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.strlitrl

Summary

The program attempts to modify a string literal.

Description

Reports attempts to modify a string literal.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.strlitrl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.strlitrl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.strstrea

Summary

Use of the header strstream and its contents.

Description

Reports use of the header strstream and its contents.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.strstrea,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.strstrea,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.strstrea,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.strstrea,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.strtwcst

Summary

The meaning of any n-char or n-wchar sequence in a string representing a NaN that is converted by the strtod, strtof, strtold, wcstod, wcstof, or wcstold function.

Description

Reports uses of strtod, strtof, strtold, wcstod, wcstof and wcstold functions in <stdlib.h> and <wchar.h> when the meaning of any n-char or n-wchar sequence in a string representing a NaN is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.strtwcst,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all calls to strtod, strtof, strtold, wcstod, wcstof and wcstold.

Configuration

See generic service options.

Option macros
macros
-config=STD.strtwcst,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.strtwcst,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.strtwcst,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.strtwcsu

Summary

Whether or not the strtod, strtof, strtold, wcstod, wcstof, or wcstold function sets errno to ERANGE when underflow occurs.

Description

Reports uses of strtod, strtof, strtold, wcstod, wcstof and wcstold functions in <stdlib.h> and <wchar.h> when it is relevant if they set errno to ERANGE when underflow occurs.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.strtwcsu,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all calls to strtod, strtof, strtold, wcstod, wcstof and wcstold.

Configuration

See generic service options.

Option macros
macros
-config=STD.strtwcsu,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.strtwcsu,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.strtwcsu,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.structma

Summary

The padding and alignment of members of structures.

Description

Reports struct/union definitions when the padding and alignment of members is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.structma,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.structma,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.structma,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.systemfn

Summary

The manner of execution of the string by the system function.

Description

Reports uses of the system function in <stdlib.h> when the manner of execution of the string by the system function is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.systemfn,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.systemfn,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.systemfn,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.systemfn,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.tempbuff

Summary

Use of deprecated methods from header memory.

Description

Reports use of deprecated functions from header memory.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.tempbuff,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option statements
statements
-config=STD.tempbuff,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.tempbuff,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.tempbuff,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.textterm

Summary

Whether the last line of a text stream requires a terminating new-line character.

Description

Reports uses of input functions and macros in <stdio.h> when it is relevant if the last line of a text stream requires a terminating new-line character.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.textterm,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.textterm,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.textterm,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.textterm,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.throwexc

Summary

Use of the exception-specifier throw().

Description

Reports use of the exception specifier throw().

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.throwexc,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.throwexc,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.throwexc,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.throwexc,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.timelocl

Summary

The local time zone and Daylight Saving Time.

Description

Reports uses of the functions ctime, localtime and mktime in <time.h> when the local time zone and Daylight Saving Time are relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.timelocl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.timelocl,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.timelocl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.timelocl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.tokenext

Summary

A non-standard token.

Description

Reports uses of non-standard tokens.

The behavior service configuration with its associated -doc line can be used to specify the non-standard tokens and their documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.tokenext,behavior={c99, "^gcc[^/]*$", "name(_Bool)||name(_Noreturn)"}

indicates that with the C99 standard and using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …), it is assumed that the _Bool and _Noreturn tokens are supported.

Note that, for this service, the report category is the reported token text.

Configuration

See generic service options.

Option std_tokens
std_tokens
-config=STD.tokenext,std_tokens=HS

Specify whether to show tokens whose spelling location is in a standard library file.

HS:

show or hide tokens whose spelling location is in a standard library file. Accepted values are:

  • show: show tokens whose spelling location is in a standard library file;

  • hide: do not show tokens whose spelling location is in a standard library file;

Default:

-config=STD.tokenext,std_tokens=hide

Option behavior
behavior
-config=STD.tokenext,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify non-standard behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

a -name_selector identifier or a matcher expression.


Rule STD.unionmbr

Summary

A member of a union object is accessed using a member of a different type.

Description

Reports uses of unions when the behavior of accessing a member stored with a different type is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.unionmbr,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option declarations
declarations
-config=STD.unionmbr,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.unionmbr,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.vaargast

Summary

The type parameter to the va_arg macro is not such that a pointer to an object of that type can be obtained simply by postfixing a *.

Description

Reports macro invocations to va_arg where its second argument does not have a type such that a pointer can be obtained by postfixing an *.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.vaargast,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.vaargast,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.vaendmi

Summary

Whether va_copy and va_end are macros or identifiers with external linkage.

Description

Reports uses of va_end when it is relevant if it is a macro or an external identifier.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.vaendmi,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.vaendmi,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.vaendmi,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.vaendmi,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.volatltp

Summary

What constitutes an access to an object that has volatile-qualified type.

Description

Reports volatile qualifiers when it is relevant what constitutes an access to an object that has volatile-qualified type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.volatltp,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all uses of the volatile qualifier.

Configuration

See generic service options.

Option statements
statements
-config=STD.volatltp,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.volatltp,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.volatltp,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.vptrarth

Summary

An arithmetic operator on void * type.

Description

Reports arithmetic operators on void * type.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.vptrarth,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.vptrarth,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.vsizaray

Summary

A variable length array.

Description

Reports variable length arrays.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C90 standard ..."
-config=STD.vsizaray,behavior={c90, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C90 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option types
types
-config=STD.vsizaray,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.vsizaray,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.vsizaray,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.widechar

Summary

The range of values of a wide character.

Description

Reports uses of wide char when its range of values is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.widechar,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option types
types
-config=STD.widechar,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.widechar,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option statements
statements
-config=STD.widechar,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.widechar,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.widechar,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.widestng

Summary

The current locale used to convert a wide string literal into corresponding wide character codes.

Description

Reports wide string literals when the locale used for converting wide characters to codes is relevant.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.widestng,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Imprecision

Cautions are reported for all wide string literals.

Configuration

See generic service options.

Option statements
statements
-config=STD.widestng,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=STD.widestng,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option behavior
behavior
-config=STD.widestng,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.witespac

Summary

Whether each nonempty sequence of white-space characters other than new-line is retained or replaced by one space character in translation phase 3.

Description

Reports if the white-space retention or replacement in translation phase 3 is unspecified.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.witespac,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option behavior
behavior
-config=STD.witespac,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.writetxt

Summary

Whether a write on a text stream causes the associated file to be truncated beyond that point.

Description

Reports uses of output functions and macros in <stdio.h> when it is relevant if a write on a text stream causes the associated file to be truncated beyond that point.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.writetxt,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.writetxt,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.writetxt,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.writetxt,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.wstrconv

Summary

Use of deprecated classes from header locale.

Description

Reports use of deprecated classes from header locale.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the deprecated behavior for the C++17 standard ..."
-config=STD.wstrconv,behavior={c++17, "^g++[^/]*$", "specified"}

indicates that the behavior is documented for the C++17 standard using any compiler invoked via the PATH environment variable whose name begins with “g++”.

Configuration

See generic service options.

Option types
types
-config=STD.wstrconv,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=STD.wstrconv,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.wstrconv,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


Rule STD.zerolnfl

Summary

Whether a zero-length file actually exists.

Description

Reports uses of functions and macros in <stdio.h> when it is relevant if a zero-length file actually exists.

The behavior service configuration with its associated -doc line can be used to specify the behavior and documentation. For example:

-doc="the behavior for the C99 standard ..."
-config=STD.zerolnfl,behavior={c99, "^gcc[^/]*$", "specified"}

indicates that the behavior is documented for the C99 standard using any compiler invoked via the PATH environment variable whose name begins with “gcc” (e.g., gcc, gcc-10, gcc-4.8, …).

Configuration

See generic service options.

Option macros
macros
-config=STD.zerolnfl,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option declarations
declarations
-config=STD.zerolnfl,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option behavior
behavior
-config=STD.zerolnfl,behavior={STDS, EXECUTABLE_MATCHER, CHOICE},...

Specify the expected behavior.

The configuration’s content is a short-circuit sequence specifying the compiler behavior for the standard and compiler. Subsequent specifications with the same exact matchers will override previous ones generating warnings. In case of multiple non-conflicting specifications, only the first that matches will be considered. The remaining ones will be silently ignored even if they match.

STDS:

a -stds identifier or a matcher expression used to select the related languages standards.

EXECUTABLE_MATCHER:

a -file_tag identifier or a matcher expression used to select tools.

CHOICE:

behavior choice. Accepted forms are:

  • specified: the behavior is specified


The TEC Coding Rules

Rule TEC.F_PROT

Summary

All function calls and definitions shall be preceded by a new-style function prototype. (See page 8 of ECMM-2005 [19] .)

Configuration

See generic service options.

Option declarations
declarations
-config=TEC.F_PROT,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


The High-Integrity C++ Coding Rules

Rule THP2.2.2

Summary

Specify in your compiler configuration that plain char is implemented as unsigned char. (See page 8 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.3.1.1

Summary

Organise class definitions by access level, in the following order : public, protected, private. (QACPP 2108, 2109, 2191, 2192, 2195). (See page 9 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.3.1.7

Summary

Do not use the inline keyword for member functions, inline functions by defining them in the class body. (QACPP 2133). (See page 11 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.1.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.1.11

Summary

Do not provide conversion operators for class types. (QACPP 2181). (See page 13 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.1.11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.1.13

Summary

Verify that all classes provide a minimal standard interface against a checklist comprising: a default constructor; a copy constructor; a copy assignment operator and a destructor. (QACPP 2110, 2111, 2112, 2114, 2142, 2185, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 2617, 2618, 2631, 2632, 2633). (See page 14 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.1.13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.2.4

Summary

An abstract class shall have no public constructors. (See page 16 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.2.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.2.6

Summary

Do not inline constructors or destructors. (See page 16 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.2.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.3.1

Summary

Use public derivation only. (QACPP 2193, 2194). (See page 16 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.3.4

Summary

Avoid casting to a virtual base class as this is irreversible. (QACPP 3071). (See page 18 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.3.3.4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.3.3.15

Summary

Ensure base classes common to more than one derived class are virtual. (QACPP 2151). (See page 21 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.3.3.16

Summary

Explicitly declare polymorphic member functions virtual in a derived class. (QACPP 2132). (See page 22 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.3.4.1

Summary

Make member data private. (QACPP 2100, 2101). (See page 22 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.4.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.5.1

Summary

Avoid overloading the comma operator (,), operator AND (&&), and operator OR (||). (QACPP 2077, 2078, 2079). (See page 25 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.5.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.5.4

Summary

Make binary operators non-members to allow implicit conversions of the left hand operand. (QACPP 2070). (See page 26 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.5.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.3.5.5

Summary

When overloading the subscript operator (operator[]) implement both const and non-const versions. (QACPP 2140, 2141). (See page 26 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.3.5.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.4.1

Summary

Do not write functions with an excessive McCabe Cyclomatic Complexity. (QACPP 5040). (See page 28 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option limit
limit
-config=THP2.4.1,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=THP2.4.1,limit=10

Option declarations
declarations
-config=THP2.4.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.4.2

Summary

Avoid functions with a high static program path count. (QACPP 5041). (See page 28 of HICPP-2006 [17] .)

Description

Functions whose number of acyclic execution paths is more than 200 are reported.

Note that the metric can be changed using the metric_show service configuration with the metric B.ACPATH_FUNC.

Configuration

See generic service options.

Option metric_show
metric_show
-config=THP2.4.2,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=THP2.4.2,metric_show={B.ACPATH_FUNC, 200}

Option declarations
declarations
-config=THP2.4.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.4.3

Summary

Avoid functions with many arguments. (QACPP 5042). (See page 28 of HICPP-2006 [17] .)

Description

Functions that have more than 6 parameters are reported.

Note that the metric can be changed using the metric_show service configuration with the metric B.PARAM_FUNC.

Configuration

See generic service options.

Option metric_default_fmt
metric_default_fmt
-config=THP2.4.3,metric_default_fmt=FMT

Specify the default format.

FMT:

the default format (see the -fmt global configuration content, template reprtmtc__id_default_fmt) that should be used if no other format is specified; it has fields:

subject_kind

subject kind;

subject_msg

subject message;

subject_name

subject name;

subject_named

Boolean indicating if the subject has a name;

metric_id

metric identifier;

metric_summary

metric summary;

lower_case_metric_summary

metric summary in lowercase;

context_kind

context kind;

context_name

context name;

context_desc

context description;

report_where

a tag with values incremental or final indicating where the metric is reported;

domain

the environment or entity where the metric is reported;

domain_msg

a message describing the environment or entity where the metric is reported;

limit

the metric limit;

rel

the relation used to compare the limit with the metric value;

good_limit

the metric limit that must not be exceeded;

subject_eq_context

Boolean indicating if the context and subject are the same;

value

the actual value for the metric.

Default:

-config=THP2.4.3,metric_default_fmt="%{__metric_value_gt_limit_fmt()}"

Option metric_show
metric_show
-config=THP2.4.3,metric_show={METRIC, LIM},...

Specify metrics to be used with hide, show or limit.

METRIC:

name of a supported metric.

LIM:

hide, show or the limit (the maximal value that is compliant) or a relation (=, <, >), followed by the value.

Default:

-config=THP2.4.3,metric_show={B.PARAM_FUNC, 6}

Option declarations
declarations
-config=THP2.4.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.5.1

Summary

Follow each flow control primitive (if, else, while, for, do and switch) by a block enclosed by braces, even if the block is empty or contains only one line. (QACPP 4013, 4014, 4016, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4068). (See page 29 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.5.2

Summary

For boolean expressions (if, for, while, do and the first operand of the ternary operator ?:) involving non-boolean values, always use an explicit test of equality or non-equality. (QACPP 3054). (See page 29 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option etypes
etypes
-config=THP2.5.2,etypes={TAGS, NODE_MATCHER, ETYPE_MATCHER},...

Specifies the report tags for essential types.

The configuration’s content is a list of clauses specifying the nodes, the essential types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NODE_MATCHER:

an expression, declaration or type whose child is an expression with a type to be checked. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||NODE_MATCHER: either the node matches AND_MATCHER or it matches NODE_MATCHER

  • -AND_MATCHER||NODE_MATCHER: the node does not match AND_MATCHER but does match NODE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (NODE_MATCHER): the node matches NODE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • any(): any node matches

  • none(): no node matches

  • implicit(): the context uses an implicit conversion

  • member_initializer(): the context node is a member initializer

  • decl(DECL_MATCHER): the context node is a declaration matching DECL_MATCHER (see the -decl_selector global configuration)

  • type(TYPE_MATCHER): the context node is a type matching TYPE_MATCHER (see the -type_selector global configuration)

  • stmt(STMT_MATCHER): the context node is an expression or statement matching STMT_MATCHER (see the -stmt_selector global configuration)

ETYPE_MATCHER:

an expression defining the etype conditions. Accepted forms are:

  • [+]AND_MATCHER: the etype matches AND_MATCHER

  • -AND_MATCHER: the etype does not match AND_MATCHER

  • [+]AND_MATCHER||ETYPE_MATCHER: either the etype matches AND_MATCHER or it matches ETYPE_MATCHER

  • -AND_MATCHER||ETYPE_MATCHER: the etype does not match AND_MATCHER but does match ETYPE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the etype matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the etype matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (ETYPE_MATCHER): the etype matches ETYPE_MATCHER

  • !BASIC_MATCHER: the etype does not match BASIC_MATCHER

  • any(): any etype matches

  • none(): no etype matches

  • 01_to_boolean(): source expression is evaluatable integer that evaluates to 0 or 1 and destination type is a Boolean

  • child(ETYPE_CHILDS): the child kind

  • dst_type(ETYPE_CONDS): the destination type conditions

  • src_type(ETYPE_CONDS): the source type conditions

  • src_expr(EXPR_CONDS): the source expression conditions

  • different_category(): the source and destination types are in different categories (which are any of [boolean, character, floating, signed, unsigned, enum, nullptr, other or void])

  • init_list_0(): the source expression is an initializer list that is a singleton with value 0

  • narrow(): the width of the destination type is less than that of the source type

  • sibling(ETYPE_CHILD,SIBLING_CONDS): the source expression has a sibling with child kind ETYPE_CHILD that satisfies one of the SIBLING_CONDSs

  • preserved_integer_constant(): the source is an integer constant expression and the destination essential type is an integer type that can represent its value

  • compatible(): the destination type is not void and the source and destination types are compatible

  • wider(): the width of the destination type is more than that of the source type

ETYPE_CHILDS

accepted forms are:

  • ETYPE_CHILD[||ETYPE_CHILD]*: the child conditions

ETYPE_CHILD

accepted forms are:

  • cond: condition

  • common: common child of a binary_conditional_operator

  • then: then child of a binary_conditional_operator or conditional_operator

  • else: else child of a binary_conditional_operator or conditional_operator

  • lhs: left-hand operand

  • rhs: right-hand operand

  • subscript: subscript expression

EXPR_CONDS

accepted forms are:

  • EXPR_COND[||EXPR_COND]*: the expression conditions

EXPR_COND

accepted forms are:

  • STMT_MATCHER: the expression matches STMT_MATCHER (see the -stmt_selector global configuration)

  • mc2_complex: source expression is complex (see page 49 of MISRA-C:2004 [62] , Section 6.10.5)

  • mc3_composite: source expression is composite (see page 98 of MISRA C:2012 [45] , Section 8.10.3)

  • mp1_cvalue: source expression is a cvalue (see page 66 of MISRA C++:2008 [64] , Section 6)

ETYPE_CONDS

accepted forms are:

  • ETYPE_COND[||ETYPE_COND]*: the essential type conditions

ETYPE_COND

accepted forms are:

  • any_boolean: type is Boolean or essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • boolean: type is Boolean

  • complete_object_pointee: type is a non-function pointer to a complete type

  • character: type is a character

  • ebool: type is essentially Boolean (see page 204 MISRA C:2012 [45] , Section 8.10)

  • enum: type is an enumerator

  • floating: type is a floating point

  • incompatible: destination type is the balancing of incompatible types

  • integer: type is integral

  • !ETYPE_CONDS: type does not satisfy ETYPE_CONDS

  • number: type is numeric

  • other: type is not a boolean, signed or unsigned integer, floating point, enumerator or character

  • signed: type is signed integral

  • signed_char: type is signed char

  • signed_small: type is signed with rank less than or equal to int

  • unsigned: type is unsigned integral

  • unsigned_char: type is unsigned char

  • void: type is void

SIBLING_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the sibling matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||SIBLING_MATCHER: either the sibling matches AND_MATCHER or it matches SIBLING_MATCHER

  • -AND_MATCHER||SIBLING_MATCHER: the sibling does not match AND_MATCHER but does match SIBLING_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the sibling matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the sibling matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (SIBLING_MATCHER): the sibling matches SIBLING_MATCHER

  • !BASIC_MATCHER: the sibling does not match BASIC_MATCHER

  • any(): any sibling matches

  • none(): no sibling matches

  • type(ETYPE_CONDS): sibling type satisfies ETYPE_CONDS

  • expr(EXPR_CONDS): sibling expression satisfies EXPR_CONDS

  • different_category(): sibling is in a different category


Rule THP2.5.3

Summary

Avoid conditional expressions that always have the same result. (QACPP 3260, 4090, 4091, 4092, 4093, 4094). (See page 29 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.5.4

Summary

Follow each non-empty case statement block in a switch statement with a break statement. (QACPP 4011, 4612). (See page 30 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option terminals
terminals
-config=THP2.5.4,terminals={TAGS, STMT_MATCHER},...

Specifies the report tags for terminal statements.

The configuration’s content is a list of clauses specifying the terminals and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select terminal statements.


Option switch_clauses
switch_clauses
-config=THP2.5.4,switch_clauses={TAGS, SWITCH_CLAUSES},...

Specify the report tags for switch statements, selected by the number of clauses and labels.

The configuration’s content is a set of pairs that associates a report tag to a constraint based on the number of the clauses and labels in a switch statement.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

SWITCH_CLAUSES:

a conjunction of switch statement constraints. Accepted forms are:

  • CONSTRAINT[&&CONSTRAINT]*: the switch statement clause matches every CONSTRAINT

CONSTRAINT

accepted forms are:

  • switch(MIN_MAX): the number of switch clauses must be in the range MIN_MAX

  • case(MIN_MAX): the number of case labels must be in the range MIN_MAX

  • default(MIN_MAX): the number of default labels must be in the range MIN_MAX

MIN_MAX

accepted forms are:

  • NUM_MINRANGE_SEPNUM_MAX: range is from NUM_MIN to NUM_MAX

  • RANGE_SEPNUM: range is all values equal or less than NUM

  • NUMRANGE_SEP: range is all values equal or more than NUM

  • NUM: range is the single value NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option ignored_comments
ignored_comments
-config=THP2.5.4,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule THP2.5.5

Summary

Do not alter a control variable in the body of a for statement. (QACPP 4235). (See page 30 of HICPP-2006 [17] .)

Description

A for statement loop counter must not be modified in the loop body.

A loop counter is a variable that is modified in the third part of the for statement head.

If it cannot be proved that a numeric loop counter in a for statement is not be modified in the loop body or its address is not taken in the function body, then the loop counter will be reported.

Configuration

See generic service options.

Rule THP2.5.7

Summary

The control variable in a for loop should be tested against a constant value, not a function or expression. (QACPP 4244). (See page 30 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option for_structure
for_structure
-config=THP2.5.7,for_structure={TAGS, STRUCTURE},...

Specify report tags for the for statement head structures.

The configuration’s content is a set of pairs that associates report tags to the head’s parts with constraints indicating if they must be present or, if present, the number of side effects.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STRUCTURE:

the for statement head matches if it satisfies all the constraints. Accepted forms are:

  • STRUCT_FORMAT[&&STRUCT_FORMAT]*: a for statement structure

STRUCT_FORMAT

accepted forms are:

  • before(STRUCT_PART): the for statement before part satisfies the STRUCT_PART constraint

  • cond(STRUCT_PART): the for statement condition part satisfies the STRUCT_PART constraint

  • after(STRUCT_PART): the for statement after part satisfies the STRUCT_PART constraint

STRUCT_PART

accepted forms are:

  • empty: the for statement part must be empty

  • non-empty: the for statement part must be non-empty

  • write(CLASS,POS_MIN_MAX): the sub-expressions of the head part or the declarations in a declaration statement (depending on the value of CLASS) must have side effects in the range POS_MIN_MAX

CLASS

accepted forms are:

  • decl: the before part is a declaration statement; each of the included declarations is checked for the number of side effects

  • expr: the part is an expression split into a comma separated list of sub-expressions; each of the sub-expressions is checked for the number of side effects

POS_MIN_MAX

accepted forms are:

  • POS_NUM_MINRANGE_SEPPOS_NUM_MAX: range is from (non-negative) POS_NUM_MIN to POS_NUM_MAX

  • POS_NUMRANGE_SEP: range is all values equal or more than (non-negative) POS_NUM

  • POS_NUM: range is the single non-negative value POS_NUM

RANGE_SEP

accepted forms are:

  • ..: range separator

  • ...: range separator


Option for_counter
for_counter
-config=THP2.5.7,for_counter={TAGS, COUNTER},...

Specify report tags for the loop counters of for statements.

The configuration’s content is a set of pairs that associates report tags to the for statement loop counter that satisfies the constraints.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COUNTER:

an expression defining the constraints on the loop counters. Accepted forms are:

  • [+]AND_MATCHER: the loop counter AND_MATCHER

  • -AND_MATCHER: the loop counter does not match AND_MATCHER

  • [+]AND_MATCHER||COUNT_MATCHER: either the loop counter matches AND_MATCHER or it matches COUNT_MATCHER

  • -AND_MATCHER||COUNT_MATCHER: the loop counter does not match AND_MATCHER but does match COUNT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the loop counter matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the loop counter matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (COUNT_MATCHER): the loop counter matches COUNT_MATCHER

  • !BASIC_MATCHER: the loop counter does not match BASIC_MATCHER

  • any(): any loop counter matches

  • none(): no loop counter matches

  • global(): the loop counter is a global variable

  • is_in_test(): the loop counter is in a relational or equality test or in a function call in the condition part of the head

  • tested_in_condition(): the loop counter is an operand of a relational or equality test or in a function call in the condition part of the head

  • tested_in_relation(): the loop counter is an operand of a relational test in the condition part of the head

  • modify_is_monotonic(): the loop counter is monotonically incremented or decremented in the after part of the head

  • taken(): the loop counter is stored or passed

  • has_body_modification(): the loop counter is modified in the body

  • variable(): the loop counter is a variable

  • single(): the loop counter is unique

  • type(TYPE_MATCHER): the loop counter has a type that matches TYPE_MATCHER (see the -type_selector global configuration)


Option for_parts
for_parts
-config=THP2.5.7,for_parts={TAGS, PARTS},...

Specify report tags for the different parts of a for statement (i.e, the three parts of the head and the body).

The configuration’s content is a list of pairs of report tags and an expression specifying constraints on the for statement’s parts.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PARTS:

an expression defining the constraints on the for statement’s parts; note that these constraints only apply if the part is non-empty. Accepted forms are:

  • [+]AND_MATCHER: the for statement AND_MATCHER

  • -AND_MATCHER: the for statement does not match AND_MATCHER

  • [+]AND_MATCHER||PARTS_MATCHER: either the for statement matches AND_MATCHER or it matches PARTS_MATCHER

  • -AND_MATCHER||PARTS_MATCHER: the for statement does not match AND_MATCHER but does match PARTS_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the for statement matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the for statement matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (PARTS_MATCHER): the for statement matches PARTS_MATCHER

  • !BASIC_MATCHER: the for statement does not match BASIC_MATCHER

  • any(): any for statement matches

  • none(): no for statement matches

  • before(BEFORE_CONSTR[&&BEFORE_CONSTR]*): the set of conditions that the before part of a for statement head must satisfy

  • cond(COND_CONSTR[&&COND_CONSTR]*): the set of conditions that the condition part of a for statement head must satisfy

  • after(AFTER_CONSTR[&&AFTER_CONSTR]*): the set of conditions that the after part of a for statement head must satisfy

  • body(BODY_CONSTR[&&BODY_CONSTR]*): the set of conditions that the body of a for statement must satisfy

BEFORE_CONSTR

accepted forms are:

  • only_init: the before part is an initializing expression or set of declarations with non-empty initializers

  • only_assign: the before part is a comma separated list of assignments or set of declarations with non-empty initializers

COND_CONSTR

accepted forms are:

  • counter_tests_are_relational: the value of numeric loop counters is tested directly or with a relational operator

  • expression_is_a_bool: the condition part is a single counter or a MISRA Boolean expression

  • tests_are_indirect: the condition part tests only uses relational or equality operators

  • counter_test_is_simple: the condition part has a simple test for the single loop counter

  • numeric_counter_tests_are_relational: the condition part tests each numeric loop counter using a relational or equality operators

  • counters_are_operands: the condition part tests each numeric loop counter using a relational or equality operators where the counter is an operand

  • counter_is_modified: a loop counter is modified in the condition part

  • taken_control_variable: the condition part does not use any taken control variable

AFTER_CONSTR

accepted forms are:

  • expression_modifies: the after part of the head is a comma sequence of expressions that only modify control variables

  • modify_is_inc_dec: the after part of the head is a comma sequence of increment or decrement expressions

  • modify_is_safe: the after part of the head increments or decrements the (single) loop counter by a constant amount and this increase or decrease is safe relative to the relation in one of the tests for that counter

  • single_write: the after part of the head is an expression that only modifies a single counter

  • modify_is_const_inc_dec: the after part of the head is a comma sequence of expressions that increment or decrement a variable by a constant amount

  • only_counter_is_modified: the after part of the head is an expression that only modifies loop counters

BODY_CONSTR

accepted forms are:

  • modified_variables_are_bool: every non-counter control variable (that is, a variable that occurs in the head) that is modified in the body has a MISRA Boolean type

  • modified_cond_variables_are_bool: every non-counter control variable that occurs in the condition part of the head and is modified in the body has a MISRA Boolean type

  • after_variable_modified: there exists a control variable that occurs in the after part of the head that is modified

  • counter_is_modified: a loop counter is modified in the body

  • has_jumps: the body contains a goto or a label statement


Rule THP2.5.8

Summary

Do not use goto. (QACPP 4000). (See page 31 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.5.8,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.5.8,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.5.10

Summary

For functions with non-void return type, ensure all paths have a return statement that contains an expression of the return type. (QACPP 4022, 4023). (See page 31 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.5.10,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.5.10,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_stmts
ignored_stmts
-config=THP2.5.10,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule THP2.6.1

Summary

Use suffixes L, U, and UL for all constants of type long, unsigned int and unsigned long. (See page 33 of HICPP-2006 [17] .)

Description

An integer constant is reported if it is used to give a value where the expected type is unsigned, long or long long and it does not have the appropriate uppercase suffixes.

Thus, for example, if a constant is used to initialize an object declared as an unsigned int or used as an operand in an expression where its type after the usual arithmetic conversions is unsigned int, then it is reported if it does not have the suffix U.

Configuration

See generic service options.

Option literals
literals
-config=THP2.6.1,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule THP2.6.2

Summary

Use suffixes F and L for all constants of type float and long double. (QACPP 3012). (See page 33 of HICPP-2006 [17] .)

Description

A floating point constant is reported if it is used to give a value where the expected type is float or long double and it does not have the appropriate uppercase suffix.

Thus, for example, if a constant is used to initialize an object declared as a float or used as an operand in an expression where its type after the usual arithmetic conversions is a float, then it is reported if it does not have the suffix F.

Configuration

See generic service options.

Option literals
literals
-config=THP2.6.2,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule THP2.6.3

Summary

Write the value of a character constant to be in the range of its type. (See page 33 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.6.4

Summary

Only use escape sequences defined by the ISO C++ Standard. (QACPP 0076, 0077, 0446, 0447). (See page 33 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.6.5

Summary

Do not write character string literal tokens adjacent to wide string literal tokens. (QACPP 5065). (See page 34 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.6.6

Summary

Global and static data should be const. (See page 34 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.6.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.7.1

Summary

Always use casting forms: static_cast, const_cast, dynamic_cast and reinterpret_cast or explicit constructor call. Do not use any other form. (QACPP 3080). (See page 35 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.7.1,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.7.2

Summary

Minimise the use of casts. (QACPP 3081). (See page 35 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.7.2,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.7.3

Summary

Avoid casting away volatile qualification. (QACPP 3061). (See page 35 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.7.3,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.7.4

Summary

Avoid casting away const qualification. (QACPP 3060). (See page 35 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.7.4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.7.5

Summary

Avoid using pointer or reference casts. (QACPP 3030, 3031). (See page 35 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.7.5,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.7.6

Summary

Do not convert floating values to integral types except through use of standard library routines. (QACPP 3011). (See page 36 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.7.6,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.7.7

Summary

Do not cast pointers to and from fundamental types. (QACPP 3036, 3037). (See page 36 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.7.7,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.8.1.1

Summary

With the exception of object definitions and unnamed namespace declarations and definitions, declare in header files: all non-inline functions, classes, variables, enumerations and enumerators, which are named at namespace scope and which have external linkage. (QACPP 5005). (See page 37 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.1.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.1.2

Summary

With the exception of unnamed namespace declarations and definitions, define in header files all inline functions which are at namespace scope and which have external linkage. (QACPP 5006). (See page 37 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.1.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.1.3

Summary

With the exception of unnamed namespace declarations and definitions, define in header files all template definitions which are at namespace scope and which have external linkage. (QACPP 5007). (See page 38 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.1.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.2.1

Summary

Do not hide declarations in other scopes. (QACPP 2500, 2501, 2502). (See page 38 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.8.2.2

Summary

Avoid global variables. (QACPP 2300, 2311). (See page 38 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.2.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.2.3

Summary

Always use using declarations or write explicit namespace qualifiers. Do not use using directives. (QACPP 5134). (See page 39 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.2.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.2.4

Summary

Only have using namespace directives in the main source file, after all include directives. (QACPP 5135). (See page 39 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.2.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.3.1

Summary

Avoid using the keyword static when declaring objects in namespaces. (QACPP 2313, 2314). (See page 39 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.3.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.3.3

Summary

Do not use the auto or register keywords. (QACPP 5069). (See page 40 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.3.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.3.4

Summary

Ensure each identifier is distinct. (QACPP 1710). (See page 40 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option ignored_decls
ignored_decls
-config=THP2.8.3.4,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_macros
ignored_macros
-config=THP2.8.3.4,ignored_macros=MACRO_MATCHER,...

Specify the macros that should be ignored.

The configuration’s content is a list of macro matchers.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule THP2.8.4.1

Summary

Do not write the characters l (ell) and 1 (one) or O (oh) and 0 (zero) in the same identifier. (QACPP 5217). (See page 40 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=THP2.8.4.1,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=THP2.8.4.1,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=THP2.8.4.1,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=THP2.8.4.1,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=THP2.8.4.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=THP2.8.4.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=THP2.8.4.1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule THP2.8.4.2

Summary

Declare each variable on a separate line in a separate declaration statement. If the declaration is not self-explanatory, append a comment describing the variable. (QACPP 4107, 4108, 5075). (See page 41 of HICPP-2006 [17] .)

Description

Each variable declarator must be on a separate line and have its own personal declaration.

Configuration

See generic service options.

Option contexts
contexts
-config=THP2.8.4.2,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.8.4.3

Summary

Initialise all objects at definition. Never use an object before it has been given a value. (QACPP 4101, 4102, 4104, 4105, 4200, 4201, 4204, 4205, 4231, 4238). (See page 41 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.4.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.4.4

Summary

Postpone variable definitions as long as possible. (See page 41 of HICPP-2006 [17] .)

Description

Reports any variable for which one of the following holds:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • it is used in a single file but declared in a different file;

  • its declaration can be moved to the initialization of a for statement.

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.8.4.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=THP2.8.4.4,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule THP2.8.4.5

Summary

Do not use the plain char type when declaring objects that are subject to numeric operations. In this case always use an explicit signed char or unsigned char declaration. (See page 42 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option calls
calls
-config=THP2.8.4.5,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule THP2.8.4.7

Summary

Declare one type name only in each typedef declaration. (QACPP 5078). (See page 42 of HICPP-2006 [17] .)

Description

Each type declarator must have its own personal declaration.

Configuration

See generic service options.

Rule THP2.8.4.8

Summary

Do not typedef array types. (QACPP 2411). (See page 42 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option types
types
-config=THP2.8.4.8,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=THP2.8.4.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.4.10

Summary

Avoid pointers to members. (QACPP 5070, 5071). (See page 43 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option types
types
-config=THP2.8.4.10,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=THP2.8.4.10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.8.4.11

Summary

Use const whenever possible. (See page 43 of HICPP-2006 [17] .)

Description

In the declarations of variables, parameters and methods, use const wherever possible.

Configuration

See generic service options.

Option show_declarations
show_declarations
-config=THP2.8.4.11,show_declarations=WHAT

Specify what declarations should be shown.

WHAT:

indicate which declarations should be shown. Accepted values are:

  • all: all the declarations are shown;

  • none: only the definition is shown;

  • param: declarations will only be shown if they do not need to have their constness changed just to ensure compilation;

  • non_param: declarations will be shown if, to ensure compilation, they must have their constness changed to be congruent to the definition (or for parameters the corresponding parameters in the function definition);

Default:

-config=THP2.8.4.11,show_declarations=all

Option single_assign
single_assign
-config=THP2.8.4.11,single_assign=BOOL

Specify if an uninitialized local variable declaration with a single assignment may be considered for converting the constness to const.

BOOL:

boolean. Accepted values are:

  • true: an uninitialized local variable declaration with a single assignment will be considered for converting the constness to const;

  • false: an uninitialized local variable declaration with a single assignment will not be considered for converting the constness to const;

Default:

-config=THP2.8.4.11,single_assign=true

Option declarations
declarations
-config=THP2.8.4.11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option ignored_decls
ignored_decls
-config=THP2.8.4.11,ignored_decls=DECL_MATCHER,...

Specify the declarations that should be ignored.

The configuration’s content is a list of declaration matchers.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=THP2.8.4.11,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule THP2.8.4.13

Summary

Prefer to use signed numeric values, not unsigned. (QACPP 3084). (See page 43 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.8.4.13,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.9.1

Summary

Do not throw exceptions from within destructors. (QACPP 4032, 4631). (See page 44 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.9.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.9.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.9.2

Summary

Only throw objects of class type. (QACPP 3500). (See page 44 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.9.3

Summary

Catch exceptions by reference. (QACPP 4031). (See page 44 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.10.1

Summary

Use symbolic names instead of literal values in code. Do not use “magic” numbers. (QACPP 4400, 4401, 4402, 4403, 4404). (See page 46 of HICPP-2006 [17] .)

Description

Each non-string literal that is not used to initialize a constant is shown unless it is:

  • the character literal ‘\0’,

  • the numeric literal 0 or 1, or

  • the boolean literal true or false.

String literals are shown if the same string occurs more than once in the code.

Configuration

See generic service options.

Option literals
literals
-config=THP2.10.1,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule THP2.10.3

Summary

Do not assume the order of evaluation of operands in an expression. (QACPP 3220, 3221). (See page 46 of HICPP-2006 [17] .)

Description

An expression is non-compliant if it has two unordered actions where:

  • both write to the same area of memory;

  • one action reads from and the other action writes to the same area of memory.

Notes:

  • It is assumed that unless a function is declared as const, pure or noeffect, any call to it may result in a change to the value of one of its arguments or to the value of a global variable.

  • The -call_properties global configuration can be used to specify the call property const, pure or noeffect.

For example, with the configuration line:

-call_properties+={"decl(name(pure_fun))", {pure}}

the function named pure_fun has the property pure and is assumed to have no side effects and will not change the value of one of its arguments or any global variable.

Imprecision

Cautions are reported when it has not been determined whether two accessed objects overlap.

Configuration

See generic service options.

Rule THP2.10.4

Summary

Use parentheses in expressions to specify the intent of the expression. (QACPP 3700). (See page 46 of HICPP-2006 [17] .)

Description

See High Integrity C++ Coding Standard, Section 5.1.3

Configuration

See generic service options.

Option trusted_pairs
trusted_pairs
-config=THP2.10.4,trusted_pairs={TAGS, PAIRS},...

Specify the tags for trusted pairs of main and child operators.

The configuration’s content is a set of tagged main and child operator pairs.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

PAIRS:

the main and child operator trusted pair. Accepted forms are:

  • OP_PAIR[||OP_PAIR]*: main and child operator pairs

OP_PAIR

accepted forms are:

  • OPERATOR_TAG1:OPERATOR_TAG2: main and child operator pair

OPERATOR_TAG

accepted forms are:

  • arrow: -> member designation operator

  • dot: . member designation operator

  • arrow_star: ->* pointer to member operator

  • dot_star: .* pointer to member operator

  • addrof: & address-of operator

  • co_await: co_await operator

  • deref: * indirection operator

  • imag: imaginary part operator

  • real: real part operator

  • plus: + unary plus operator

  • minus: - unary minus operator

  • not: ~ one’s complement operator

  • lnot: ! logical negation operator

  • post_dec: -- postfix decrement operator

  • post_inc: ++ postfix increment operator

  • pre_dec: -- prefix decrement operator

  • pre_inc: ++ prefix increment operator

  • sizeof_expr: sizeof operator

  • sizeof_type: sizeof operator

  • alignof_expr: alignof operator

  • alignof_type: alignof operator

  • vec_step_expr: vec_step operator

  • vec_step_type: vec_step operator

  • extension: extension operator

  • div: / division operator

  • mul: * multiplication operator

  • rem: % remainder operator

  • add: + addition operator

  • sub: - subtraction operator

  • shl: << left shift operator

  • shr: >> right shift operator

  • ge: >= greater-than or equal operator

  • gt: > greater-than operator

  • le: <= less-than or equal operator

  • lt: < less-than operator

  • eq: == equality operator

  • ne: != inequality operator

  • and: & bitwise AND operator

  • or: | bitwise OR operator

  • xor: ^ bitwise XOR operator

  • land: && logical AND operator

  • lor: || logical OR operator

  • conditional: ?: conditional operator

  • binary_conditional: ?: binary conditional operator

  • assign: = assignment operator

  • add_assign: += addition assignment operator

  • and_assign: &= bitwise AND assignment operator

  • div_assign: /= division assignment operator

  • mul_assign: *= multiplication assignment operator

  • or_assign: |= bitwise OR assignment operator

  • rem_assign: %= remainder assignment operator

  • shl_assign: <<= left shift assignment operator

  • shr_assign: >>= right shift assignment operator

  • sub_assign: -= subtraction assignment operator

  • xor_assign: ^= bitwise XOR assignment operator

  • throw: throw operator

  • comma: , comma operator

  • OP_COLLECTION: operator collections

OP_COLLECTION

accepted forms are:

  • multiplicative: *, / or % operator

  • additive: + or - operator

  • equality: == or != operator

  • relational: <, <=, > or >= operator

  • bitwise: ^, & or | operator

  • binary_logical: || or &&

  • logical: ||, && or ! operator

  • arithmetic: +, -, *, /, %, real or imag operator

  • assignment: =, +=, &=, /=, *=, <<=, >>=, -= or ^= operator


Rule THP2.10.5

Summary

Always discard the result of an assignment operator. (QACPP 4071). (See page 46 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.5,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.10.5,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.10.6

Summary

When comparing variables and constants for equality always place the constant on the left hand side. (See page 47 of HICPP-2006 [17] .)

Description

Reports when constants are not on the left of the equality == operator.

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.6,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.10.6,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.10.7

Summary

Do not use expressions which rely on implicit conversion of an operand. (QACPP 0150, 3000, 3001, 3010, 3011, 3012, 3050, 3051, 3054, 3062, 3072, 3073). (See page 47 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.10.7,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.10.8

Summary

Ensure expressions used in assertions are free from side-effects. (See page 47 of HICPP-2006 [17] .)

Description

Assertions must not contain side effects.

Note that assertions may only contain calls to functions that have been declared to have property noeffect (to specify call properties, use the -call_properties global configuration).

Configuration

See generic service options.

Option effects
effects
-config=THP2.10.8,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule THP2.10.9

Summary

Do not code side effects into the right-hand operands of &&, ||, sizeof or typeid. (QACPP 3230, 3240, 3241). (See page 48 of HICPP-2006 [17] .)

Description

typeid, sizeof and the right-hand operand of a logical && or || operator must not contain side effects.

Note that, the expressions may only contain calls to functions that have been declared to have property noeffect (to specify call properties, use the -call_properties global configuration).

Configuration

See generic service options.

Option effects
effects
-config=THP2.10.9,effects={TAGS, CONDS},...

Specifies the report tags for effects.

The configuration’s content is a list of report tags with a set of conditions on the effects found within the context specified by the guideline.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONDS:

the effects found in the expression and its context must match CONDS. Accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||CONDS: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||CONDS: the effects do not match AND_MATCHER but do match CONDS

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CONDS): the effects match CONDS

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • count(RANGE,EFFECT_MATCHER): the context’s effects must satisfy RANGE and EFFECT_MATCHER

  • empty stringEFFECT_KIND: one of the expression’s effects must match EFFECT_KIND

EFFECT_MATCHER

accepted forms are:

  • EFFECT_MATCHER[&&EFFECT_MATCHER]*): the constraint is one of the EFFECT_MATCHER

RANGE

accepted forms are:

  • all: there can be any number of effects

  • any: there must be at least one effect

  • MIN_MAX: the number of effects must be in the range MIN_MAX

EFFECT_MATCHER

accepted forms are:

  • [+]AND_MATCHER: the effects matches AND_MATCHER

  • -AND_MATCHER: the effects does not match AND_MATCHER

  • [+]AND_MATCHER||EFFECT_MATCHER: either the effects match AND_MATCHER or match EFFECT_MATCHER

  • -AND_MATCHER||EFFECT_MATCHER: the effects do not match AND_MATCHER but do match EFFECT_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the effects match BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the effects match BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EFFECT_MATCHER): the effects match EFFECT_MATCHER

  • !BASIC_MATCHER: the effects do not match BASIC_MATCHER

  • any(): any effects match

  • none(): no effects match

  • EFFECT_KIND: an effect matches EFFECT_KIND

EFFECT_KIND

accepted forms are:

  • asm: an asm

  • call: a call

  • const: call with property const

  • exit: exit

  • indirect_jump: an indirect jump

  • jump: jump

  • leave: leave

  • loop: loop

  • noeffect: call with property noeffect

  • nothrow: call with property nothrow

  • pure: call with property pure

  • read: read

  • read_write: read/write

  • throw: throw

  • unevaluated: an unevaluated expression

  • volatile: reference to a volatile

  • write: write


Rule THP2.10.10

Summary

Avoid statements that have no side effects. (QACPP 3242, 3243, 3244, 3245). (See page 48 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.10.11

Summary

Do not apply the following bitwise operators to signed operands: shift operators (<<, >>), bitwise AND (&), exclusive OR (^) and inclusive OR (|). (QACPP 3003). (See page 48 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.11,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.10.11,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.10.12

Summary

Validate arguments to be used in shift operators. (QACPP 3321, 3322). (See page 49 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.10.15

Summary

Do not write code that expects floating point calculations to yield exact results. (QACPP 3270, 4234). (See page 49 of HICPP-2006 [17] .)

Imprecision

False negatives are present because recognising indirect equality and inequality tests is undecidable.

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.15,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option ignored_stmts
ignored_stmts
-config=THP2.10.15,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule THP2.10.16

Summary

Do not use the increment operator (++) on a variable of type bool. (QACPP 3291). (See page 49 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.16,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.10.16,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.10.19

Summary

Do not use the comma operator. (QACPP 3243). (See page 50 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.19,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.10.19,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.10.20

Summary

Do not use the ternary operator (?:) in expressions. (QACPP 3380, 3381, 3382, 3383, 3384, 3385, 3386). (See page 50 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.20,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.10.20,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.10.21

Summary

Apply unary minus to operands of signed type only. (QACPP 3002). (See page 50 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option statements
statements
-config=THP2.10.21,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=THP2.10.21,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule THP2.11.2

Summary

Enclose all non-member functions that are not part of the external interface in the unnamed namespace in the source file. (See page 51 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.11.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.11.3

Summary

Specify the name of each function parameter in both the function declaration and the function definition. Use the same names in the function declaration and definition. (QACPP 2017). (See page 51 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.11.3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.11.6

Summary

Do not use ellipsis ... in function parameters. (QACPP 3074). (See page 52 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.11.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.11.7

Summary

A function should not return a reference or a pointer to an automatic variable defined within the function. Instead, it should return a copy of the object. (QACPP 4026, 4027, 4028). (See page 52 of HICPP-2006 [17] .)

Description

It is shown if a pointer or reference to an object with automatic storage is returned by a function.

Configuration

See generic service options.

Rule THP2.11.8

Summary

Only declare trivial functions inline. (QACPP 2133, 2134, 4120, 4121). (See page 52 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option limit
limit
-config=THP2.11.8,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=THP2.11.8,limit=5

Option declarations
declarations
-config=THP2.11.8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.12.2

Summary

Allocate memory using new and release using delete. Do not use the C memory management functions malloc(), realloc(), and free(). (QACPP 3332, 3334, 3901). (See page 54 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.12.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.12.7

Summary

Document that operator new and operator delete are static by declaring them static. (QACPP 2162). (See page 55 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.12.7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.13.3

Summary

Do not exceed the translation limits imposed by the ISO C++ Standard. (See page 56 of HICPP-2006 [17] .)

Description

The code must not exceed the implementation’s limits.

This service depends upon the configuration of the following ancillary services: STD.argfcall STD.argmcall STD.blkident STD.byteobjt STD.caselimt STD.charline STD.charstrl STD.cissnest STD.cnstenum STD.extident STD.extidsig STD.inclnest STD.macident STD.membrecd STD.nexidsig STD.paramfun STD.parammac STD.pexpnest STD.ppifnest STD.ptypnest STD.recdnest STD.decllimt

Configuration

See generic service options.

Option behaviors
behaviors
-config=THP2.13.3,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=THP2.13.3,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=THP2.13.3,standards=c++

Rule THP2.13.4

Summary

Do not use compiler specific language or pre-processor extensions. (QACPP 0027, 0028, 0029, 0060, 0095, 1040). (See page 56 of HICPP-2006 [17] .)This service depends upon the configuration of the following ancillary services: STD.adrslabl STD.anonfild STD.araystat STD.arayzero STD.argfcall STD.argmcall STD.bincondl STD.bitfwdth STD.blkident STD.byteobjt STD.caselimt STD.caseuplw STD.castunon STD.charescp STD.charline STD.charstrl STD.cissnest STD.cmntstle STD.cmpdltrl STD.cnstenum STD.decllimt STD.declmixd STD.decltype STD.desginit STD.diag STD.dupldecl STD.emptmarg STD.enumlist STD.extident STD.flexaray STD.forhdecl STD.freestlb STD.funojptr STD.iddollar STD.implfunc STD.inclnest STD.indxcnst STD.indxvltl STD.ltrlbin STD.ltrlhxfl STD.ltrllnln STD.macident STD.macrsynt STD.macrvarg STD.mainrtrn STD.membrecd STD.ncstinit STD.nodecltr STD.paramfun STD.parammac STD.pexpnest STD.ppcomma STD.ppifnest STD.pteincmp STD.ptypnest STD.recdnest STD.redltype STD.rtrnemty STD.rvalsubs STD.stdtypes STD.stmtexpr STD.strincmp STD.tokenext STD.vptrarth STD.vsizaray

Configuration

See generic service options.

Option behaviors
behaviors
-config=THP2.13.4,behaviors={TAGS, BEHAVIOR_MATCHER},...

Specifies the behaviors and ancillary services to be tagged.

The configuration’s content is associate report tags to behavior matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

BEHAVIOR_MATCHER:

an expression selecting behaviors. Accepted forms are:

  • [+]AND_MATCHER: the behavior matches AND_MATCHER

  • -AND_MATCHER: the behavior does not match AND_MATCHER

  • [+]AND_MATCHER||BEHAVIOR_MATCHER: either the behavior matches AND_MATCHER or it matches BEHAVIOR_MATCHER

  • -AND_MATCHER||BEHAVIOR_MATCHER: the behavior does not match AND_MATCHER but does match BEHAVIOR_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the behavior matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the behavior matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (BEHAVIOR_MATCHER): the behavior matches BEHAVIOR_MATCHER

  • !BASIC_MATCHER: the behavior does not match BASIC_MATCHER

  • any(): any behavior matches

  • none(): no behavior matches

  • report(CLASS[||CLASS]*): the report class matches one of the classes

  • standard(CLASS[||CLASS]*): the standard class matches one of the classes

  • service(SERVICE_MATCHER): the behavior referring is for an ancillary service matching SERVICE_MATCHER (see the -service_selector global configuration)

  • category(REGEX): the behavior category matches ^REGEX$

REGEX

accepted forms are:

CLASS

accepted forms are:

  • implementation: implementation-defined

  • ill_formed: ill-formed

  • undefined: undefined

  • unspecified_critical: unspecified and critical

  • unspecified_not_critical: unspecified and not critical

  • unspecified: unspecified

  • limit: implementation limit


Option standards
standards
-config=THP2.13.4,standards=STDS,...

Specify the allowed standards.

{STDS,…}:

set of allowed standards. Accepted members are:

  • STD: a -stds identifier or a matcher expression used to select the related languages standards.

Default:

-config=THP2.13.4,standards=c++03

Rule THP2.13.5

Summary

Do not use the asm declaration. (QACPP 1100). (See page 56 of HICPP-2006 [17] .)

Description

A function is non-compliant if it contains an unencapsulated asm statement and a non-asm statement Notes:

  • Expressions and statements specified using the configuration parameters ignored_stmts service configurations are said to be ignored.

  • A macro that contains, other than ignored code, only asm statements is considered a valid asm encapsulator.

  • A function that contains, other than ignored code, only asm statements, possibly expanded from asm encapsulator macros, or calls to asm encapsulator functions is considered a valid asm encapsulator.

  • Any asm statements that are expanded from a macro or in a macro-defined do-while-zero loop idiom are ignored.

Configuration

See generic service options.

Option ignored_stmts
ignored_stmts
-config=THP2.13.5,ignored_stmts={CTXT_MATCHER, STMT_MATCHER},...

Specify the stmts that should be ignored.

The configuration’s content is a list of clauses specifying the stmts.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the stmt contexts.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the stmts.


Rule THP2.13.7

Summary

Do not cast a pointer to fundamental type, to a pointer to a more restrictively aligned fundamental type. (QACPP 3033). (See page 57 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.13.7,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.14.1

Summary

Use the C++ comment delimiters “//”. Do not use the C comment delimiters “/* … */”. (QACPP 1050). (See page 58 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option comments
comments
-config=THP2.14.1,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule THP2.14.2

Summary

Do not use tab characters in source files. (QACPP 5200). (See page 58 of HICPP-2006 [17] .)

Description

The <TAB> character must not be used.

Configuration

See generic service options.

Rule THP2.14.3

Summary

Write pre-processor directives to begin in column 1 with no whitespace between the # and the pre-processor directive. (QACPP 5229). (See page 58 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.14.7

Summary

Do not include comment text in the definition of a pre-processor macro. (QACPP 5117). (See page 59 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.14.9

Summary

Use <> brackets for system and standard library headers. Use "" quotes for all other headers. (QACPP 1011, 1012). (See page 59 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=THP2.14.9,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=THP2.14.9,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule THP2.14.10

Summary

Do not include a path specifier in file names supplied in #include directives. (QACPP 1010, 1013). (See page 59 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=THP2.14.10,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=THP2.14.10,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule THP2.14.11

Summary

Incorporate include guards in header files to prevent multiple inclusions of the same file. (QACPP 0063, 0103, 1000, 1001). (See page 60 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option directives
directives
-config=THP2.14.11,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule THP2.14.12

Summary

Use lower-case for file names and references to file names (such as include directives). (QACPP 5121). (See page 60 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option path_uses_backslash
path_uses_backslash
-config=THP2.14.12,path_uses_backslash=BACKSLASH_EXCEPTION

Specify a deviation to allow for the use of the backslash in directory paths.

BACKSLASH_EXCEPTION:

indicate whether a backslash is allowed in the file name. Accepted values are:

  • false: use the default file name check;

  • true: do not report the use of a backslash in a file name;


Option include_name_exception
include_name_exception
-config=THP2.14.12,include_name_exception={TAGS, NAME_MATCHER},...

Specify tags for #include header names.

The configuration’s content is a set of tags for matching #include header names.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the #include header names.


Rule THP2.14.14

Summary

Enclose macro arguments and body in parentheses. (QACPP 1030, 1031). (See page 60 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option param_parentheses
param_parentheses
-config=THP2.14.14,param_parentheses=CONDS,...

Specify conditions when parameter parentheses are not required.

The configuration’s content is a short-circuit sequence of macro parameter parentheses.

CONDS:

conditions for parameter parentheses. Accepted forms are:

  • binary_op(): the parameter is an argument to a binary operator

  • unary_op(): the parameter is an argument to a unary operator

  • conditional_op(): the parameter is an argument to a conditional operator

  • pre(PRE_POST_EXPR): the tokens before the parameter must match PRE_POST_EXPR

  • post(PRE_POST_EXPR): the tokens after the parameter must match PRE_POST_EXPR

  • pre_post(PRE_POST_EXPR0,PRE_POST_EXPR1): the tokens before the parameter must match PRE_POST_EXPR0 and the tokens after the parameter must match PRE_POST_EXPR1

PRE_POST_EXPR

accepted forms are:

  • QSTRING: quoted token sequence

  • QSTRING||PRE_POST_EXPR: alternative quoted token sequences

Default:

-config=THP2.14.14,param_parentheses="pre('->'||'.')"

Option macros
macros
-config=THP2.14.14,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule THP2.14.15

Summary

Do not use pre-processor macros to define code segments. (QACPP 1023). (See page 61 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option macros
macros
-config=THP2.14.15,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule THP2.14.16

Summary

Do not use the NULL macro. (QACPP 1024). (See page 61 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option macros
macros
-config=THP2.14.16,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule THP2.14.17

Summary

Use const objects or enumerators to define constants, not #define. (QACPP 1020, 1021). (See page 61 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option macros
macros
-config=THP2.14.17,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule THP2.14.18

Summary

Do not use digraphs or trigraphs. (QACPP 5210). (See page 61 of HICPP-2006 [17] .)

Configuration

See generic service options.

Rule THP2.14.19

Summary

Do not use function macros, use inline functions instead. (QACPP 1020). (See page 62 of HICPP-2006 [17] .)

Imprecision

Cautions are reported when criteria have not been precisely determined.

Criteria such as the trade-off between code size and execution speed are not considered.

Configuration

See generic service options.

Option macro_argument_context
macro_argument_context
-config=THP2.14.19,macro_argument_context=CONTEXT_MATCHER,...

Specifies contexts of macro arguments that should be ignored.

The configuration’s content is a list of clauses specifying contexts for macro argument.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select contexts of macro arguments.

Default:

-config=THP2.14.19,macro_argument_context="std(c)&&skip_to(class(type||expr||decl,any),
      stmt_child(operator(sizeof||alignof), expr)||
      stmt_child(node(generic_selection_expr),cond)||
      type_child(node(typeof_expr),expr)||
      decl_child(__any_var_decls&&type(node(auto)),init))", "std(c)&&!skip_to(__non_syntactic_or_paren_contexts,
      stmt(rvalue()))"

Option macros
macros
-config=THP2.14.19,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Rule THP2.15.1

Summary

Do not use variant structures (unions). (QACPP 2176). (See page 63 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.15.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=THP2.15.1,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule THP2.15.2

Summary

Do not include member functions or access specifiers in struct types. (QACPP 2171, 2173, 2175). (See page 63 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option declarations
declarations
-config=THP2.15.2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule THP2.15.4

Summary

Avoid casting an integer to an enumeration as the result of this cast is unspecified if the value is not within the range of the enumeration. (QACPP 3013). (See page 63 of HICPP-2006 [17] .)

Configuration

See generic service options.

Option casts
casts
-config=THP2.15.4,casts={TAGS, MATCHER},...

Specifies the report tags for casts.

The configuration’s content is a list of clauses specifying the casts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MATCHER:

comma-separated sequence of cast conditions. Accepted forms are:

  • [+]AND_MATCHER: the node matches AND_MATCHER

  • -AND_MATCHER: the node does not match AND_MATCHER

  • [+]AND_MATCHER||CAST_MATCHER: either the cast matches AND_MATCHER or it matches CAST_MATCHER

  • -AND_MATCHER||CAST_MATCHER: the cast does not match AND_MATCHER but does match CAST_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the cast matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the cast matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (CAST_MATCHER): the cast matches CAST_MATCHER

  • !BASIC_MATCHER: the cast does not match BASIC_MATCHER

  • any(): any cast matches

  • none(): no cast matches

  • class(CAST_CLASS): the cast class is CAST_CLASS

  • context(CONTEXT_MATCHER): the cast is in a context matching CONTEXT_MATCHER (see the -context_selector global configuration)

  • from(FROM_MATCHER): the cast whose source expression matches FROM_MATCHER

  • syntactic(FROM_MATCHER)): the cast whose syntactic source expression (i.e., after removing all non-syntactic wrappers from the source) matches FROM_MATCHER

  • kind(CAST_KIND[||CAST_KIND]*): the cast kind is one of the CAST_KIND

  • language(LANGUAGE): the language is LANGUAGE

  • to(type(TYPE_MATCHER)): the cast whose destination type is matching TYPE_MATCHER (see the -type_selector global configuration)

  • relation(RELATION[||RELATION]*): the cast satisfies one of RELATION

CAST_KIND

accepted forms are:

  • no_op: no_op

  • address_space_conversion: address_space_conversion

  • array_to_pointer_decay: array_to_pointer_decay

  • atomic_to_non_atomic: atomic_to_non_atomic

  • base_to_derived: base_to_derived

  • base_to_derived_member_pointer: base_to_derived_member_pointer

  • bitcast: bitcast

  • boolean_to_signed_integral: boolean_to_signed_integral

  • builtin_function_to_pointer_decay: builtin_function_to_pointer_decay

  • constructor_conversion: constructor_conversion

  • dependent: dependent

  • derived_to_base: derived_to_base

  • derived_to_base_member_pointer: derived_to_base_member_pointer

  • dynamic: dynamic

  • floating_cast: floating_cast

  • floating_complex_cast: floating_complex_cast

  • floating_complex_to_boolean: floating_complex_to_boolean

  • floating_complex_to_integral_complex: floating_complex_to_integral_complex

  • floating_complex_to_real: floating_complex_to_real

  • floating_real_to_complex: floating_real_to_complex

  • floating_to_boolean: floating_to_boolean

  • floating_to_integral: floating_to_integral

  • function_to_pointer_decay: function_to_pointer_decay

  • integral_cast: integral_cast

  • integral_complex_cast: integral_complex_cast

  • integral_complex_to_boolean: integral_complex_to_boolean

  • integral_complex_to_floating_complex: integral_complex_to_floating_complex

  • integral_complex_to_real: integral_complex_to_real

  • integral_real_to_complex: integral_real_to_complex

  • integral_to_boolean: integral_to_boolean

  • integral_to_floating: integral_to_floating

  • integral_to_pointer: integral_to_pointer

  • lvalue_bitcast: lvalue_bitcast

  • lvalue_to_rvalue: lvalue_to_rvalue

  • member_pointer_to_boolean: member_pointer_to_boolean

  • non_atomic_to_atomic: non_atomic_to_atomic

  • null_to_member_pointer: null_to_member_pointer

  • null_to_pointer: null_to_pointer

  • pointer_to_boolean: pointer_to_boolean

  • pointer_to_integral: pointer_to_integral

  • reinterpret_member_pointer: reinterpret_member_pointer

  • to_union: to_union

  • to_void: to_void

  • unchecked_derived_to_base: unchecked_derived_to_base

  • user_defined_conversion: user_defined_conversion

  • vector_splat: vector_splat

CAST_CLASS

accepted forms are:

  • implicit: the cast is implicit

  • explicit: the cast is explicit

  • c_style: the cast is c_style

  • functional: the cast is functional

  • const: the cast is a const named cast

  • dynamic: the cast is a dynamic named cast

  • reinterpret: the cast is a reinterpret named cast

  • static: the cast is a static named cast

RELATION

accepted forms are:

  • : bigger_sizea cast to a bigger type

  • : bigger_size_pointeea cast from a pointer to another pointer with a bigger pointee

  • cast_away_const: a cast from a pointer to a const type to a pointer without the qualifier

  • cast_away_volatile: a cast from a pointer to a volatile type to a pointer without the qualifier

  • compatible_deep_unqualified: a cast from a type to a type that has the same pointee depth and where the innermost types without qualifiers are compatible

  • definitely_changes_value: a cast that definitely does change the source expression’s value

  • definitely_in_range: a cast whose cast value is definitely in the range of its type

  • definitely_out_range: a cast whose cast value is definitely out of range of its type

  • definitely_preserves_value: a cast that definitely does not change the source expression’s value

  • derived_to_virtual_base: a cast from a pointer to a class to a pointer to a virtual base class

  • enum_constant: a cast whose source expression is an enumeration constant and whose destination type is the same as the enumerator type

  • forget_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const or is void or Boolean

  • forget_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile or is void or Boolean

  • incompatible_unqualified_pointee: a cast from a pointer to a pointer with an incompatible unqualified pointee type

  • more_aligned_pointee: a cast from a pointer to a pointer with a more aligned pointee type

  • polymorphic_base_to_derived: a cast from a pointer to a base class with polymorphic type to a pointer to a derived class

  • qualification: a cast from a pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_from_void_pointee: a cast from a void pointer to another pointer where the destination pointee has all the qualifiers in the source pointee

  • qualification_to_void_pointee: a cast from a pointer to void pointer where the destination pointee has all the qualifiers in the source pointee

  • same_type: a cast that does not change the type

  • same_unqualified_pointee: a cast from a pointer to a pointer with the same pointee type, ignoring any qualifications

  • signed_to_unsigned: a cast from a signed integral type to an unsigned integral type

  • unqualify_const_pointee: a cast from a pointer with a const pointee type to another pointer whose pointee type is not const

  • unqualify_pointee: a cast from a pointer with a pointee type qualifier to another pointer whose pointee type does not have that qualifier

  • unqualify_volatile_pointee: a cast from a pointer with a volatile pointee type to another pointer whose pointee type is not volatile

  • unqualify_atomic_pointee: a cast from a pointer with an _Atomic pointee type to another pointer whose pointee is not _Atomic

  • unsigned_to_signed: a cast from an unsigned integral type to a signed integral type

  • virtual_base_to_derived: a cast from a pointer to a virtual base class to a pointer to a derived class

FROM_MATCHER

accepted forms are:

  • type(TYPE_MATCHER): the type of the source expression matches TYPE_MATCHER (see the -type_selector global configuration)

  • expr(STMT_MATCHER): the source expression matches STMT_MATCHER (see the -stmt_selector global configuration)

LANGUAGE

accepted forms are:

  • c: C

  • cpp: C++


Rule THP2.17.1

Summary

Use Standard C++ Library headers defined by the language standard and not outdated .h headers. For example, use <iostream> and not <iostream.h>, <cstdio> and not <stdio.h>. (QACPP 1014). (See page 67 of HICPP-2006 [17] .)

Description

There must be no use of the C library.

Configuration

See generic service options.

The LSST-DM-C++:2009 Coding Rules

Rule TLP1.5-16

Summary

do-while loops SHOULD be avoided. (See http://dev.lsstcorp.org/trac/wiki/C%2B%2BStandard/Statements#a5-16.do-whileloopsSHOULDbeavoided. .)

Configuration

See generic service options.

Option statements
statements
-config=TLP1.5-16,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=TLP1.5-16,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule TLP1.5-23

Summary

Functions MUST always have the return value explicitly listed. (See http://dev.lsstcorp.org/trac/wiki/C%2B%2BStandard/Statements#a5-23.FunctionsMUSTalwayshavethereturnvalueexplicitlylisted. .)

Configuration

See generic service options.

Option declarations
declarations
-config=TLP1.5-23,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule TLP1.5-30

Summary

The use of magic numbers in the code SHOULD be avoided. (See http://dev.lsstcorp.org/trac/wiki/C%2B%2BStandard/Statements#a5-30.TheuseofmagicnumbersinthecodeSHOULDbeavoided. .)

Configuration

See generic service options.

Option literal_matches
literal_matches
-config=TLP1.5-30,literal_matches={TAG, {LIT_COND,...}},...

Specify what is a magic constant.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

LIT_COND:

literal condition. Accepted alternatives are:

  • {ancestors, CTXT}: .

    CTXT:

    a -context_selector identifier or a matcher expression used to select the contexts.

  • {exact_macro_expansion}: an exact macro expansion.

  • {paren_macro_expansion}: a parenthesized macro expansion.

  • {in_macro_body}: literal is in macro body.

  • {expanded_from_macro, MACRO_MATCHER}: expanded from matching macro.

    MACRO_MATCHER:

    a -macro_selector identifier or a matcher expression used to select the macros.

  • {text, TEXT_RE}: regular expression to match literal.

    TEXT_RE:

    constant text matcher.

  • {character_literal}: character literal.

  • {wide_char_literal}: wide char literal.

  • {utf16_char_literal}: utf16 char literal.

  • {utf32_char_literal}: utf32 char literal.

  • {floating_literal}: floating literal.

  • {integer_literal}: integer literal.

  • {string_literal}: string literal.

  • {wide_string_literal}: wide string literal.

  • {utf8_string_literal}: utf8 string literal.

  • {utf16_string_literal}: utf16 string literal.

  • {utf32_string_literal}: utf32 string literal.

Default:

-config=TLP1.5-30,literal_matches={hide, {{paren_macro_expansion}}}, {hide, {{integer_literal}, {text, "^(0|-?1|2)[LUlu]*$"}}}, {hide, {{character_literal}, {text, "^'.'$"}}}, {hide, {{string_literal}, {text, "^\".?\"$"}}}, {hide, {{ancestors, __indirect_init_contexts}}}

Option literal_kinds
literal_kinds
-config=TLP1.5-30,literal_kinds=LIT,...

Specify the kinds of literals to be checked.

{LIT,…}:

the literal families to be checked. Accepted members are:

  • floating_literal: floating literal;

  • integer_literal: integer literal;

  • character_literal: character literal;

  • string_literal: string literal;

  • ordinary: ordinary character or string literal;

  • wide: wide character or string literal;

  • utf16: utf16 character or string literal;

  • utf32: utf32 char literal;

  • utf8: utf8 string literal;

Default:

-config=TLP1.5-30,literal_kinds=character_literal, integer_literal, floating_literal, string_literal

Option literals
literals
-config=TLP1.5-30,literals={TAGS, LITERAL_MATCHER},...

Specifies the report tags for literals.

The configuration’s content is a list of clauses specifying the literals and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

LITERAL_MATCHER:

an expression defining the matching literal (see -stmt_selector global configuration).


Rule TLP1.5-33

Summary

goto SHOULD not be used. (See http://dev.lsstcorp.org/trac/wiki/C%2B%2BStandard/Statements#a5-33.gotoSHOULDnotbeused. .)

Configuration

See generic service options.

Option statements
statements
-config=TLP1.5-33,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=TLP1.5-33,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


The Power of Ten Coding Rules

Rule TTC.1

Summary

Restrict to simple control flow constructs. (See http://spinroot.com/p10/rule1.html , page 2 of P10-C-2006 [23] .)

Description

Reports all of the following:

  • goto (including indirect goto) statements,

  • any use of the library functions setjmp or longjmp,

  • direct and indirect recursive functions.

Configuration

See generic service options.

Option declarations
declarations
-config=TTC.1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=TTC.1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option statements
statements
-config=TTC.1,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=TTC.1,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Option ignored_edges
ignored_edges
-config=TTC.1,ignored_edges=EDGE_MATCHER

Specifies which call edges should be ignored to determine the reachability of entities.

EDGE_MATCHER:

matcher that defines the call edges that are ignored to delimit the reachability perimeter. Accepted forms are:

  • [+]AND_MATCHER: the edge matches AND_MATCHER

  • -AND_MATCHER: the edge does not match AND_MATCHER

  • [+]AND_MATCHER||EDGE_MATCHER: either the node matches AND_MATCHER or it matches EDGE_MATCHER

  • -AND_MATCHER||EDGE_MATCHER: the node does not match AND_MATCHER but does match EDGE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the node matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the node matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • (EDGE_MATCHER): the node matches EDGE_MATCHER

  • !BASIC_MATCHER: the node does not match BASIC_MATCHER

  • from(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the caller entity in the call edge

  • to(ENTITY_MATCHER): a -entity_selector identifier or a matcher expression used to select the callee entity in the call edge


Rule TTC.3

Summary

Do not use dynamic memory allocation after initialization. (See http://spinroot.com/p10/rule3.html , page 2 of P10-C-2006 [23] .)

Description

Reports any use of the functions malloc, calloc, realloc or free or the operators new or delete.

Configuration

See generic service options.

Option extra_statements
extra_statements
-config=TTC.3,extra_statements={STMT_MATCHER, CTXT_MATCHER},...

Specify statement matcher.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the statements or the expressions.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.

Default:

-config=TTC.3,extra_statements={}

Option statements
statements
-config=TTC.3,statements={TAGS, STMT_MATCHER},...

Specifies the report tags for statements.

The configuration’s content is a list of clauses specifying the statements and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

STMT_MATCHER:

a -stmt_selector identifier or a matcher expression used to select the expressions or the statements.


Option contexts
contexts
-config=TTC.3,contexts={TAGS, CONTEXT_MATCHER},...

Specifies the report tags for contexts.

The configuration’s content is a list of clauses specifying the contexts and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CONTEXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the contexts.


Rule TTC.4

Summary

Limit functions to no more than N lines of text. (See http://spinroot.com/p10/rule4.html , page 3 of P10-C-2006 [23] .)

Description

Reports any function that has more than M logical lines of source code.

The default maximum number of lines is 60 but this can be changed using the limit service configuration.

Configuration

See generic service options.

Option limit
limit
-config=TTC.4,limit=LIMIT

Specify the complexity limit.

LIMIT:

the limiting value. It must be an integer greater than or equal to 0.

Default:

-config=TTC.4,limit=60

Option declarations
declarations
-config=TTC.4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule TTC.5

Summary

Use minimally N assertions for every function of more than M lines. (See http://spinroot.com/p10/rule5.html , page 3 of P10-C-2006 [23] .)

Description

Reports any function that has more than 10 logical lines of source code (lsloc) and does not have at least 1 assertion.

Note that:

Configuration

See generic service options.

Option function_size_metrics
function_size_metrics
-config=TTC.5,function_size_metrics={NAME, METRIC},...

Specify reference names with metrics.

The configuration’s content is an ordered list of reference names with metrics.

NAME:

a reference name.

METRIC:

a metric.

Default:

-config=TTC.5,function_size_metrics={params, B.PARAM_FUNC}, {size, B.LSLOCS_FUNC}

Option call_assertions
call_assertions
-config=TTC.5,call_assertions={TNAME, MIN, BOUND},...

Specify the complexity thresholds for an interesting function together with an expression defining a lower bound for the expected number of assertions in the function.

The configuration’s content is a list of pairs (MIN, BOUND) linking a complexity threshold with an evaluable term that indicates the minimum number of assertions; any function exceeding the complexity threshold but with less than the minimum number of assertions is reported.

TNAME:

a name already defined by the function_size_metrics service configuration for the metric whose value is to be compared to MIN.

MIN:

threshold for function size measured using TNAME. It must be an integer greater than or equal to 1.

BOUND:

an evaluable (Prolog-like) expression using complexity measures with variable names defined by the function_size_metrics service configuration; the number of special calls must be more that the value of this expression.

Default:

-config=TTC.5,call_assertions={size, 10, 1}

Option functions
functions
-config=TTC.5,functions=SPECIAL_FUN,...

Set of special function names.

{SPECIAL_FUN,…}:

a set of special function names. Accepted members are:

  • SPECIAL_FUN: function to be counted as special.

Default:

-config=TTC.5,functions=c_assert

Option special_macro
special_macro
-config=TTC.5,special_macro=SPECIAL_MACRO,...

Set of special macro names.

{SPECIAL_MACRO,…}:

a set of special macro names.set of special macro names. Accepted members are:

  • SPECIAL_MACRO: macro to be counted as special.

Default:

-config=TTC.5,special_macro=c_assert

Option declarations
declarations
-config=TTC.5,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule TTC.6

Summary

Declare data objects at the smallest possible level of scope. (See http://spinroot.com/p10/rule6.html , page 4 of P10-C-2006 [23] .)

Description

Reports any variable for which one of the following holds:

  • it can be declared in a smaller block;

  • it is used in a single function but does not have function scope;

  • it is used in a single file but declared in a different file;

  • its declaration can be moved to the initialization of a for statement.

Configuration

See generic service options.

Option declarations
declarations
-config=TTC.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option all_decls
all_decls
-config=TTC.6,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule TTC.8

Summary

Limit the use of the preprocessor to file inclusion and simple macros. (See http://spinroot.com/p10/rule8.html , page 4 of P10-C-2006 [23] .)

Description

Reports the use of a preprocessor directive if:

  • the preprocessor directive is #define and one of the following hold:

    • the definition is not in a header file,

    • the macro is used recursively,

    • the macro has a variable argument list,

    • the macro body does not expand to a complete syntactic unit, (see Rule 19.4 on page 84 of MISRA-C:2004 [62] ),

    • the macro body includes # or ##;

  • the preprocessor directive is not #define and is not part of an inclusion guard (using any of the mechanisms: #pragma, #if !defined, #ifndef, #if defined or #ifdef).

Note that, for this service, the report category is the directive name.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=TTC.8,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option macros
macros
-config=TTC.8,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option directives
directives
-config=TTC.8,directives={TAGS, DIR_MATCHER},...

Specifies the report tags for directives.

The configuration’s content is a list of clauses specifying the directives and the related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DIR_MATCHER:

an expression defining the matching directive. Accepted forms are:

  • [+]AND_MATCHER: the directive matches AND_MATCHER

  • -AND_MATCHER: the directive does not match AND_MATCHER

  • [+]AND_MATCHER||DIRECTIVE_MATCHER: either the directive matches AND_MATCHER or it matches DIRECTIVE_MATCHER

  • -AND_MATCHER||DIRECTIVE_MATCHER: the directive does not match AND_MATCHER but does match DIRECTIVE_MATCHER

AND_MATCHER

accepted forms are:

  • BASIC_MATCHER: the directive matches BASIC_MATCHER

  • BASIC_MATCHER&&AND_MATCHER: the directive matches BASIC_MATCHER and AND_MATCHER

BASIC_MATCHER

accepted forms are:

  • dir(DIR[||DIR]*): the directive matches one of the directives

  • ^REGEX$: the directive matches ^REGEX$

  • id(^REGEX$): the directive identifier matches ^REGEX$

REGEX

accepted forms are:


Rule TTC.9

Summary

Limit the use of pointers. (See http://spinroot.com/p10/rule9.html , page 5 of P10-C-2006 [23] .)

Description

Reports:

  • if any of the following types has more than 1 level of pointer indirection:

    • the declared type of an object,

    • the return type of a function,

    • the type of a cast expression,

    • the type name argument to sizeof,

    • the type name argument in a compound literal expression,

    • the type of an expression;

  • if a typedef declaration has a pointer indirection;

  • if a macro definition has a pointer dereference;

  • any use of a function pointer.

Configuration

See generic service options.

Option types
types
-config=TTC.9,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Option declarations
declarations
-config=TTC.9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule TTC.10

Summary

Compile with all warnings enabled, in pedantic mode, and use one or more modern static source code analyzers. (See http://spinroot.com/p10/rule10.html , page 5 of P10-C-2006 [23] .)

Description

Reports if a compiler or linker does not have all the warnings enabled.

The hidden_options service configuration can be used to specify deviations.

Configuration

See generic service options.

Option hidden_options
hidden_options
-config=TTC.10,hidden_options={TAGS, TOOL, {OPTION_MATCHER,...}},...

Specify tags for command lines that match the option selectors.

The configuration’s content is list of tagged option matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TOOL:

tool kind. Accepted values are:

  • compiler: compiler tool;

  • linker: linker tool;

OPTION_MATCHER:

option matcher string. Accepted forms are:

  • ^REGEX$: option matches ^REGEX$

  • !OPTION_MATCHER: option does not match OPTION_MATCHER

  • ID: option matches one of the patterns listed in ecl variable ID (a name beginning with a letter)

  • TEXT: option matches string TEXT

REGEX

accepted forms are:


The Geant Project Coding Standard

Note that the Geant project coding rules are only informally described in [69] and are not associated to a unique identifier in that document. The ECLAIR services supporting Geant project rules are identified by the prefix UCGP1.

Rule UCGP1.C1

Summary

Comment content should be compliant. (See http://geant.cern.ch/content/coding-standards#commenting .)

Description

Checks that:

  • comments only use words in the specified vocabulary;

  • the character sequences /* and // are not used inside a comment;

  • line-splicing is not used inside // BCPL style comments;

  • comments do not begin with a lowercase letter;

  • comments end with a sentence terminator (full-stop, exclamation mark or question mark);

  • each sentence terminator in the comment is not be followed by a lowercase letter.

Note that for this rule, a comment refers to a sequence of BCPL comment lines with no separating blank lines or a single C-style comment.

Configuration

See generic service options.

Option comments
comments
-config=UCGP1.C1,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option project_dictionary
project_dictionary
-config=UCGP1.C1,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=UCGP1.C1,project_dictionary=""

Option context_dictionary
context_dictionary
-config=UCGP1.C1,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=UCGP1.C1,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=UCGP1.C1,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=UCGP1.C1,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=UCGP1.C1,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=UCGP1.C1,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=UCGP1.C1,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=UCGP1.C1,max_no_case_length=16

Option good_words_file
good_words_file
-config=UCGP1.C1,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=UCGP1.C1,good_words_file=""

Option bad_words_file
bad_words_file
-config=UCGP1.C1,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=UCGP1.C1,bad_words_file=""

Option good_items_file
good_items_file
-config=UCGP1.C1,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=UCGP1.C1,good_items_file=""

Option bad_items_file
bad_items_file
-config=UCGP1.C1,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=UCGP1.C1,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=UCGP1.C1,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=UCGP1.C1,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=UCGP1.C1,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=UCGP1.C1,bad_item_regexs={}

Option comment_regexs
comment_regexs
-config=UCGP1.C1,comment_regexs=SPLITTER,...

A list of regular expressions defining comment splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

  • SPLITTER: regular expression defining a custom splitter.


Option ignored_comments
ignored_comments
-config=UCGP1.C1,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option verbatim
verbatim
-config=UCGP1.C1,verbatim=WORDS,...

Words to be written verbatim, matching case.

{WORDS,…}:

words to be written verbatim. Accepted members are:

  • WORD: verbatim word.

Default:

-config=UCGP1.C1,verbatim=geantV

Option abbreviation
abbreviation
-config=UCGP1.C1,abbreviation=WORDS,...

Abbreviations whose terminating . is not necessarily terminating a sentence.

{WORDS,…}:

abbreviation words. Accepted members are:

  • WORD: abbreviation word.

Default:

-config=UCGP1.C1,abbreviation=etc, eg, e.g, no

Rule UCGP1.C2

Summary

Compliant file comment is required. (See http://geant.cern.ch/content/coding-standards#file-headers .)

Description

All files must begin with a standard file comment block as described in Coding standards for the Geant project.

Note: that the default comment matchers can be changed using the file_comment_block service configuration where @file_name@ can be used as a place-holder for the file name.

Configuration

See generic service options.

Option file_comment_block
file_comment_block
-config=UCGP1.C2,file_comment_block={FILE_MATCHER, {{COMMENT_MATCHER, SEP},...}},...

Provide file matchers with matchers for their initial comment block.

The configuration’s content is an ordered list of file matchers with matchers for their initial comment block.

FILE_MATCHER:

matcher for selected files (see the -file_tag global configuration).

COMMENT_MATCHER:

regular expression or ‘*’. Accepted forms are:

  • FMT: format (see the -fmt global configuration content, template cmntfile__id_default_fmt) for a regular expression that matches the expected comment using fields:

file_name

the file name;

upper_case_file_name

the file name where the alphabetic characters are changed to uppercase.

  • *: depending on the value of the separator, the following comment lines can be skipped

SEP:

if matcher is a regular expression, this is the number of blank lines after comment; if matcher is * skip SEP comments. Accepted forms are:

  • MIN_MAX: the the number of blank lines is in the range MIN_MAX

Default:

-config=UCGP1.C2,file_comment_block={"^.*\\.h\\z$", {{"%{__line1_comment_fmt()}", 0..}, {"%{__line_empty_comment_fmt()}", 0..}, {"%{__line_ignore_comment_fmt()}", 0..}, {"%{__line_empty_comment_fmt()}", 0..}, {"%{__line_ignore_comment_fmt()}", 0..}, {"%{__line_ignore_comment_fmt()}", 0..}, {"%{__line_empty_comment_fmt()}", 0..}, {"%{__line_seperator_comment_fmt()}", 0..}, {"%{__dox_empty_comment_fmt()}", 0..}, {"%{__dox_file_comment_fmt()}", 0..}, {"%{__dox_brief_comment_fmt()}", 0..}, {*, 0..}, {"%{__dox_empty_comment_fmt()}", 0..}, {"%{__line_seperator_comment_fmt()}", 0..}}}, {"^.*\\.c(c|pp)?\\z$", {{"%{__line1_comment_fmt()}", 0..}, {"%{__line_empty_comment_fmt()}", 0..}, {"%{__line_ignore_comment_fmt()}", 0..}, {"%{__line_empty_comment_fmt()}", 0..}, {"%{__line_ignore_comment_fmt()}", 0..}, {"%{__line_ignore_comment_fmt()}", 0..}, {"%{__line_empty_comment_fmt()}", 0..}, {"%{__line_seperator_comment_fmt()}", 0..}, {"%{__dox_empty_comment_fmt()}", 0..}, {"%{__dox_file_comment_fmt()}", 0..}, {"%{__dox_brief_comment_fmt()}", 0..}, {*, 0..}, {"%{__dox_empty_comment_fmt()}", 0..}, {"%{__line_seperator_comment_fmt()}", 0..}}}

Option ignored_comments
ignored_comments
-config=UCGP1.C2,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule UCGP1.C3

Summary

Compliant class comment is required. (See http://geant.cern.ch/content/coding-standards#class-overviews .)

Description

Each class definition must be immediately preceded by a comment block.

The default comment style is Doxygen, but this can be changed using the user_doc_report service configuration with the selector-id class.

Configuration

See generic service options.

Option trivial_body
trivial_body
-config=UCGP1.C3,trivial_body={ALG, MIN},...

Specify conditions for a trivial function body.

The configuration’s content is a list of algorithms and minimum complexities for a trivial function body.

ALG:

metric name.

MIN:

maximum allowed complexity measured by metric in the function body. It must be an integer greater than or equal to 0.

Default:

-config=UCGP1.C3,trivial_body={}

Option user_doc_report
user_doc_report
-config=UCGP1.C3,user_doc_report={SEL_ID, {STYLE,...}},...

Specify how the declarations must be documented.

The configuration’s content is an ordered list of selector ids and styles.

SEL_ID:

a selector id.

{STYLE,…}:

a documentation style. Accepted members are:

  • doxygen: doxygen style;

Default:

-config=UCGP1.C3,user_doc_report={}

Option declarations
declarations
-config=UCGP1.C3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule UCGP1.C4

Summary

Compliant function/method comment is required. (See http://geant.cern.ch/content/coding-standards#method-information .)

Description

Each global function and method declaration must be preceded by a comment block.

The default comment style is Doxygen, but this can be changed using the user_doc_report service configuration with the selector-id function or method for global functions or methods, respectively.

Configuration

See generic service options.

Option trivial_body
trivial_body
-config=UCGP1.C4,trivial_body={ALG, MIN},...

Specify conditions for a trivial function body.

The configuration’s content is a list of algorithms and minimum complexities for a trivial function body.

ALG:

metric name.

MIN:

maximum allowed complexity measured by metric in the function body. It must be an integer greater than or equal to 0.

Default:

-config=UCGP1.C4,trivial_body={}

Option user_doc_report
user_doc_report
-config=UCGP1.C4,user_doc_report={SEL_ID, {STYLE,...}},...

Specify how the declarations must be documented.

The configuration’s content is an ordered list of selector ids and styles.

SEL_ID:

a selector id.

{STYLE,…}:

a documentation style. Accepted members are:

  • doxygen: doxygen style;

Default:

-config=UCGP1.C4,user_doc_report={}

Option declarations
declarations
-config=UCGP1.C4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule UCGP1.C5

Summary

C++ comment style is preferred. (See http://geant.cern.ch/content/coding-standards#comment-formatting .)

Description

The /* ... */ comment style must not be used in C++ code.

Configuration

See generic service options.

Option comments
comments
-config=UCGP1.C5,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Rule UCGP1.C6

Summary

Commenting large code area should be avoided. (See http://geant.cern.ch/content/coding-standards#comment-formatting .)

Description

Large blocks of code must not be commented out.

Imprecision

False positives are reported because code and text not always distinguishable.

Some comments that use several keywords and operators may be wrongly flagged as commented code.

False negatives are present because commented code, particularly when it has very few tokens, may not be detected as code.

There exists no way to distinguish code from ordinary text; consider the following example:

#define This int
#define a =
#define comment 5;

/* This is a comment */

Configuration

See generic service options.

Option comments
comments
-config=UCGP1.C6,comments={TAGS, COMMENT_MATCHER},...

Specifies the report tags for comments.

The configuration’s content is a list of clauses specifying the comments and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option code_lines
code_lines
-config=UCGP1.C6,code_lines=LINES

Specify the minimum number of consecutive (non-blank) lines of commented code; set the value to 0, if no check on the number of lines is needed.

LINES:

minimum number of consecutive (non-blank) lines of commented code (note that blank lines in the code block, possibly in a comment, are ignored); if the value is 0, then there is no check on the number of lines. It must be an integer greater than or equal to 0.

Default:

-config=UCGP1.C6,code_lines=12

Option ignored_comments
ignored_comments
-config=UCGP1.C6,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.

Default:

-config=UCGP1.C6,ignored_comments=__doxygen_comments

Rule UCGP1.C7

Summary

Comment should be Doxygen-compliant. (See http://geant.cern.ch/content/coding-standards#doxygen-use-in-documentation-comments .)

Description

Code must use valid doxygen comments.

Note that all parameters should be documented with a separate \param description.

The doxygen_text_regex service configuration can be used suppress the report for the specified doxygen command with text matching the regular expression.

Configuration

See generic service options.

Option doxygen_text_regex
doxygen_text_regex
-config=UCGP1.C7,doxygen_text_regex={TAGS, COMMAND, REGEX},...

Specify tags for commands with the matching doxygen lines.

The configuration’s content is a tuple with three terms: a report tag, a doxygen command and a regular expression.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

COMMAND:

doxygen command. Accepted values are:

  • return: return command;

  • param: param command;

  • tparam: tparam command;

  • unknown: unknown command;

  • union: union command;

  • struct: struct command;

  • class: class command;

  • function: function command;

  • callback: callback command;

  • brief: brief command;

  • deprecated: deprecated command;

REGEX:

if the text following COMMAND matches REGEX, then any report will be tagged by TAG.


Rule UCGP1.F1

Summary

#include order should be compliant. (See http://geant.cern.ch/content/coding-standards#include-style .)

Description

The #include directives must be in the defined areas; those that are in the same area must be in lexicographic order.

Note:

  • the area consisting of header files that have the same base name as the includer file is called main;

  • an area can be the file tag;

  • the user-defined areas for the files are defined by the include_areas service configuration;

  • the order of these areas is specified by the include_order service configuration.

Configuration

See generic service options.

Option include_areas
include_areas
-config=UCGP1.F1,include_areas={AREA, INCLUDER, INCLUDED},...

Specify the area name and file name matchers for the included and includer files.

The configuration’s content is an ordered list of triples that combines the area name with file name matchers for the includer and the included file names. For any pair of includer and included file names, the area used for the ordering will be the one associated with the first pair of matching file name matchers.

AREA:

the area name used to define the include directive order.

INCLUDER:

matcher for includer files (see the -file_tag global configuration).

INCLUDED:

matcher for included files (see the -file_tag global configuration).

Default:

-config=UCGP1.F1,include_areas={std_std, "header&&std()", "header&&std()"}, {user_std, "!std()", "header&&std()"}, {main, "^([^\\.]*).*\\.(cpp|cc|c)$", "^.*@1@\\..*$"}, {local, "!std()", "any()"}

Option area_property
area_property
-config=UCGP1.F1,area_property={AREA, MIN, MAX, SORTED},...

Specify the areas’ properties.

AREA:

the area must be as specified by the include_areas service configuration.

MIN:

there must be at least this number of include directives for AREA for each file matching an includer file matcher defined in the config option include_areas. It must be an integer greater than or equal to 0.

MAX:

there must be no more than this number of include directives for AREA for each file matching the includer file matcher defined in the config option include_areas; a value of 0 indicates that there must be no include directives from this area in any matching file; a value of -1 indicates there is no upper limit. It must be an integer greater than or equal to -1.

SORTED:

within a file, the include directives for AREA must be in lexicographic order. Accepted values are:

  • true;

  • false;

Default:

-config=UCGP1.F1,area_property={main, 0, -1, true}, {local, 0, -1, true}, {user_std, 0, -1, true}

Option include_order
include_order
-config=UCGP1.F1,include_order=AREA,...

Specify the area names in the order required by the include directives.

The configuration’s content is a list of the area names in the order required by the include directives.

AREA:

the area name must be as specified by the include_areas service configuration.

Default:

-config=UCGP1.F1,include_order=main, local, user_std

Rule UCGP1.F2

Summary

Use spaces instead of tabs. (See http://geant.cern.ch/content/coding-standards#use-spaces-instead-of-tabs .)

Description

Any use of the tab character will be shown.

Configuration

See generic service options.

Rule UCGP1.H1

Summary

File name should be compliant. (See http://geant.cern.ch/content/coding-standards#header-file-name .)

Description

Each file’s base name, without any extensions, should match the unqualified name of an external entity (other than a namespace) that is declared in that file.

Configuration

See generic service options.

Option file_name
file_name
-config=UCGP1.H1,file_name={FILE_MATCHER, DECL_MATCHER, FILE_REPLACE, QUAL, DECL_REPLACE, FMT},...

Specifies file and declaration matchers with 2 replacement maps; one for the file base name and the other for the fully qualified declaration name; it is shown if a matching declaration name maps to a string that differs from the mapped file name.

The configuration’s content is an ordered list of file and decl matchers with file name and declaration name replacement maps.

FILE_MATCHER:

a -file_tag identifier or a matcher expression used to select the files.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

FILE_REPLACE:

the file name replacer REPLACER (see the -replacer global configuration).

QUAL:

use qualified or unqualified name. Accepted values are:

DECL_REPLACE:

either empty (in which case the declaration name is used unchanged) or the declaration name replacer REPLACER (see the -replacer global configuration); the replaced file name must equal a replaced declaration name.

FMT:

message format (see the -fmt global configuration content, template filndecl__default_fmt).

Default:

-config=UCGP1.H1,file_name={"any()", "-node(namespace_decl)||__any_external_decls", __remove_ext_repl, any, "", "%{__filndecl_fmt()}"}

Rule UCGP1.H4

Summary

Use early exits and continue to simplify code. (See http://geant.cern.ch/content/coding-standards#use-early-exits-and-continue-to-simplify-code .)

Description

Early exit should be preferred.

Configuration

See generic service options.

Rule UCGP1.H5

Summary

Don’t use else after a return. (See http://geant.cern.ch/content/coding-standards#don-t-use-else-after-a-return .)

Description

There must be no unnecessary use of else.

Configuration

See generic service options.

Rule UCGP1.H6

Summary

Turn predicate loops into predicate functions. (See http://geant.cern.ch/content/coding-standards#turn-predicate-loops-into-predicate-functions .)

Description

Loops that uses a number of local variables declared outside the loop itself not greater than the value given by the max_variables service configuration are shown.

A loop is considered already encapsulated if it is located at top level of function body and all other loops in the function are nested inside it.

Configuration

See generic service options.

Option max_variables
max_variables
-config=UCGP1.H6,max_variables=MAX

Specify the maximum number of outer variables used in loop.

MAX:

maximum number of outer local variables used in loop.

Default:

-config=UCGP1.H6,max_variables=3

Rule UCGP1.L1

Summary

Name types, functions, variables, and enumerators properly. (See http://geant.cern.ch/content/coding-standards#name-types-functions-variables-and-enumerators-properly .)

Description

The user-defined unqualified names, (apart from any specified subscript) must be in camel-case where:

  • namespace names begin with lowercase;

  • class, struct and union type names begin with uppercase;

  • typedef names begin with uppercase and end with _t;

  • enum type names begin with E followed by another uppercase;

  • local variable names (including function parameters) should be in camel-case and begin with a lowercase letter;

  • non-static member names begin with f followed by an uppercase letter;

  • names of local static variables and global variables begin with g followed by an uppercase letter;

  • non-constant static members names begin with fg followed by an uppercase letter;

  • enum constant names begin either with k or with a character string followed by _, an optional k and then the descriptive part that uses the specified vocabulary;

  • other constant names begin with k;

  • function names begin with lowercase;

  • class method names can either use a mix of lowercase and _s (an exception to the general requirement to use camel-case) or use begin with lowercase;

  • template type names begin with uppercase and end with T or can be the single letter T;

  • template nontype names begin with lowercase and end with T.

In addition the names (excluding any required prefix or subscript) must use the specified vocabulary.

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=UCGP1.L1,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=UCGP1.L1,project_dictionary=""

Option context_dictionary
context_dictionary
-config=UCGP1.L1,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=UCGP1.L1,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=UCGP1.L1,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=UCGP1.L1,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=UCGP1.L1,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=UCGP1.L1,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=UCGP1.L1,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=UCGP1.L1,max_no_case_length=16

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCGP1.L1,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCGP1.L1,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCGP1.L1,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCGP1.L1,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCGP1.L1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCGP1.L1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCGP1.L1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option good_words_file
good_words_file
-config=UCGP1.L1,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=UCGP1.L1,good_words_file=""

Option bad_words_file
bad_words_file
-config=UCGP1.L1,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=UCGP1.L1,bad_words_file=""

Option good_items_file
good_items_file
-config=UCGP1.L1,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=UCGP1.L1,good_items_file=""

Option bad_items_file
bad_items_file
-config=UCGP1.L1,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=UCGP1.L1,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=UCGP1.L1,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=UCGP1.L1,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=UCGP1.L1,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=UCGP1.L1,bad_item_regexs={}

Rule UCGP1.L2

Summary

Assert liberally. (See http://geant.cern.ch/content/coding-standards#assert-liberally .)

Description

Reports any function that has more than 10 logical lines of source code (lsloc) and does not have at least 1 assertion.

Note that:

Configuration

See generic service options.

Option function_size_metrics
function_size_metrics
-config=UCGP1.L2,function_size_metrics={NAME, METRIC},...

Specify reference names with metrics.

The configuration’s content is an ordered list of reference names with metrics.

NAME:

a reference name.

METRIC:

a metric.

Default:

-config=UCGP1.L2,function_size_metrics={params, B.PARAM_FUNC}, {size, B.LSLOCS_FUNC}

Option call_assertions
call_assertions
-config=UCGP1.L2,call_assertions={TNAME, MIN, BOUND},...

Specify the complexity thresholds for an interesting function together with an expression defining a lower bound for the expected number of assertions in the function.

The configuration’s content is a list of pairs (MIN, BOUND) linking a complexity threshold with an evaluable term that indicates the minimum number of assertions; any function exceeding the complexity threshold but with less than the minimum number of assertions is reported.

TNAME:

a name already defined by the function_size_metrics service configuration for the metric whose value is to be compared to MIN.

MIN:

threshold for function size measured using TNAME. It must be an integer greater than or equal to 1.

BOUND:

an evaluable (Prolog-like) expression using complexity measures with variable names defined by the function_size_metrics service configuration; the number of special calls must be more that the value of this expression.

Default:

-config=UCGP1.L2,call_assertions={size, 10, 1}

Option functions
functions
-config=UCGP1.L2,functions=SPECIAL_FUN,...

Set of special function names.

{SPECIAL_FUN,…}:

a set of special function names. Accepted members are:

  • SPECIAL_FUN: function to be counted as special.

Default:

-config=UCGP1.L2,functions=assert

Option special_macro
special_macro
-config=UCGP1.L2,special_macro=SPECIAL_MACRO,...

Set of special macro names.

{SPECIAL_MACRO,…}:

a set of special macro names.set of special macro names. Accepted members are:

  • SPECIAL_MACRO: macro to be counted as special.

Default:

-config=UCGP1.L2,special_macro=assert

Option declarations
declarations
-config=UCGP1.L2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule UCGP1.L3

Summary

Do not use using namespace std. (See http://geant.cern.ch/content/coding-standards#do-not-use-using-namespace-std .)

Description

The using declaration must not be used with the std namespace.

Configuration

See generic service options.

Option declarations
declarations
-config=UCGP1.L3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule UCGP1.L4

Summary

Provide a virtual method anchor for classes in headers. (See http://geant.cern.ch/content/coding-standards#provide-a-virtual-method-anchor-for-classes-in-headers .)

Description

A class with a vtable must have at least one out-of-line virtual method in the class.

Configuration

See generic service options.

Rule UCGP1.L5

Summary

Don’t evaluate end() every time through a loop. (See http://geant.cern.ch/content/coding-standards#don-t-evaluate-end-every-time-through-a-loop .)

Description

A call to end(), rend(), begin() or rbegin() must:

  • never occur in the condition part of a do or while loop;

  • never occur in the condition or after part of a for loop;

  • if in a loop statement, only occur in the rhs of an assignment or in an initialization.

Configuration

See generic service options.

Option calls
calls
-config=UCGP1.L5,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Rule UCGP1.L6

Summary

#include <iostream> is forbidden. (See http://geant.cern.ch/content/coding-standards#include-iostream-is-forbidden .)

Description

The non-skipped compiled file contents must not include the standard library header iostream.

Configuration

See generic service options.

Rule UCGP1.L7

Summary

Avoid std::endl. (See http://geant.cern.ch/content/coding-standards#avoid-std-endl .)

Description

The non-skipped compiled file contents must not use the standard library function endl provided by ostream.

Configuration

See generic service options.

Rule UCGP1.L8

Summary

Don’t use inline when defining a function in a class definition. (See http://geant.cern.ch/content/coding-standards#don-t-use-inline-when-defining-a-function-in-a-class-definition .)

Description

Member functions defined in a class declaration must not use the inline keyword.

Configuration

See generic service options.

Option declarations
declarations
-config=UCGP1.L8,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule UCGP1.M1

Summary

Parenthesis spacing should be compliant. (See http://geant.cern.ch/content/coding-standards#spaces-before-parentheses .)

Description

Between an identifier or a keyword and an open parenthesis there should be a space only for control flow statements.

A space is accepted also where to remove it would change the source semantics.

Configuration

See generic service options.

Rule UCGP1.M2

Summary

Prefer preincrement. (See http://geant.cern.ch/content/coding-standards#prefer-preincrement .)

Description

The value of a post-increment or post-decrement expression should be used.

Configuration

See generic service options.

Rule UCGP1.M3

Summary

static is preferred to anonymous namespace; more than one declaration in the same anonymous namespace should be avoided. (See http://geant.cern.ch/content/coding-standards#anonymous-namespaces .)

Description

The extent of anonymous namespaces should be kept minimum.

Configuration

See generic service options.

Rule UCGP1.M4

Summary

Type qualifiers position should be compliant. (See http://geant.cern.ch/content/coding-standards#const-qualifier .)

Description

The type qualifiers should be put before the base type if and only if all qualifiers can be put before the base type.

Configuration

See generic service options.

Rule UCGP1.M5

Summary

Type sigil spacing should be compliant. (See http://geant.cern.ch/content/coding-standards#braces-and-spaces .)

Description

The type sigil should not be preceded by an identifier or a keyword and should not be followed by a space.

Configuration

See generic service options.

Rule UCGP1.S1

Summary

Treat compiler warnings like errors. (See http://geant.cern.ch/content/coding-standards#treat-compiler-warnings-like-errors .)

Description

The compiler and linker (and any other tools used to build the sources) must use options that treat warnings as errors.

Configuration

See generic service options.

Option hidden_options
hidden_options
-config=UCGP1.S1,hidden_options={TAGS, TOOL, {OPTION_MATCHER,...}},...

Specify tags for command lines that match the option selectors.

The configuration’s content is list of tagged option matchers.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TOOL:

tool kind. Accepted values are:

  • compiler: compiler tool;

  • linker: linker tool;

OPTION_MATCHER:

option matcher string. Accepted forms are:

  • ^REGEX$: option matches ^REGEX$

  • !OPTION_MATCHER: option does not match OPTION_MATCHER

  • ID: option matches one of the patterns listed in ecl variable ID (a name beginning with a letter)

  • TEXT: option matches string TEXT

REGEX

accepted forms are:


Rule UCGP1.S3

Summary

Do not use static constructors. (See http://geant.cern.ch/content/coding-standards#do-not-use-static-constructors .)

Description

Static constructors and destructors must not be used.

Configuration

See generic service options.

Option declarations
declarations
-config=UCGP1.S3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Rule UCGP1.S4

Summary

Record tag incongruence should be avoided. (See http://geant.cern.ch/content/coding-standards#use-of-class-and-struct-keywords .)

Description

All declarations of a class or struct must use the same class or struct keyword.

Configuration

See generic service options.

Rule UCGP1.S5

Summary

Do not use braced initializer lists to call a constructor. (See http://geant.cern.ch/content/coding-standards#do-not-use-braced-initializer-lists-to-call-a-constructor .)

Description

The list initializers should be avoided.

Configuration

See generic service options.

Rule UCGP1.S6

Summary

Use auto type deduction to make code more readable. (See http://geant.cern.ch/content/coding-standards#use-auto-type-deduction-to-make-code-more-readable .)

Description

auto should be used only with initializers having a written type or for iterators.

Configuration

See generic service options.

Rule UCGP1.S7

Summary

Beware unnecessary copies with auto. (See http://geant.cern.ch/content/coding-standards#beware-unnecessary-copies-with-auto .)

Description

Reports variables with auto type without * for deduced pointer types and without & for lvalues whose copy is not cheap.

Copy is considered cheap if type is trivially copyable and size is <= 8 bytes.

Configuration

See generic service options.

Coverage of Geant Coding Rules

The following table presents a concise summary of the coverage provided by this version of ECLAIR for the Geant coding rules [69]. The table adopts the following conventions:

  • The Id column contains the rule identifier. The mapping between the Geant coding rule and the complete ECLAIR rule identifier is one-to-one and straightforward: e.g., Geant coding rule L1 is rule UCGP1.L1 in ECLAIR.

  • Rule identifiers written in boldface font (e.g., L1) denote required rules; rule identifiers written in normal weight font denote advisory rules.

  • The Summary column gives the rule summary.

  • The Precision column provides a short executive summary of the precision of the ECLAIR checker with respect to the rule. More precisely, that column contains:

    • Complete, when, to the best of our knowledge, the interpretation of the rule given in the ECLAIR manual is what is implemented by the checker and every possible non-compliance is reported.

    • Heuristic, when the checker for an undecidable rule uses a heuristic aimed at reducing the number of false alarms.

    • Best-effort, when the checker does not report all the non-compliances of the rule, when the rule is interpreted as explained in the ECLAIR manual.

    • Process, when the rule does not ask for specific results but for the adoption of means and/or processes.

    Note that every violation report is sound, while caution reports should be checked by user for correctness.

    For non-exact checkers, a hint about the reason for the imprecision is also given: do refer to the detailed rule descriptions for a proper treatment of the matter.

UCGP1 synopsis: supported Geant coding rules

Id

Summary

Precision

UCGP1.C1

Comment content should be compliant

Exact

UCGP1.C2

Compliant file comment is required

Exact

UCGP1.C3

Compliant class comment is required

Exact

UCGP1.C4

Compliant function/method comment is required

Exact

UCGP1.C5

C++ comment style is preferred

Exact

UCGP1.C6

Commenting large code area should be avoided

Heuristic

UCGP1.C7

Comment should be Doxygen-compliant

Exact

UCGP1.F1

#include order should be compliant

Exact

UCGP1.F2

Use spaces instead of tabs

Exact

UCGP1.H1

File name should be compliant

Exact

UCGP1.H4

Use early exits and continue to simplify code

Exact

UCGP1.H5

Don’t use else after a return

Exact

UCGP1.H6

Turn predicate loops into predicate functions

Exact

UCGP1.L1

Name types, functions, variables, and enumerators properly

Exact

UCGP1.L2

Assert liberally

Exact

UCGP1.L3

Do not use using namespace std

Exact

UCGP1.L4

Provide a virtual method anchor for classes in headers

Exact

UCGP1.L5

Don’t evaluate end() every time through a loop

Exact

UCGP1.L6

#include <iostream> is forbidden

Exact

UCGP1.L7

Avoid std::endl

Exact

UCGP1.L8

Don’t use inline when defining a function in a class definition

Exact

UCGP1.M1

Parenthesis spacing should be compliant

Exact

UCGP1.M2

Prefer preincrement

Exact

UCGP1.M3

static is preferred to anonymous namespace; more than one declaration in the same anonymous namespace should be avoided

Exact

UCGP1.M4

Type qualifiers position should be compliant

Exact

UCGP1.M5

Type sigil spacing should be compliant

Exact

UCGP1.S1

Treat compiler warnings like errors

Exact

UCGP1.S3

Do not use static constructors

Exact

UCGP1.S4

Record tag incongruence should be avoided

Exact

UCGP1.S5

Do not use braced initializer lists to call a constructor

Exact

UCGP1.S6

Use auto type deduction to make code more readable

Exact

UCGP1.S7

Beware unnecessary copies with auto

Exact

The Revised [LHCb] C++ Coding Conventions

Rule UCLP1.R27

Summary

Virtual functions should be re-declared virtual in derived classes, just for clarity. And also to avoid mistakes when deriving a class from this derived class. (See page 7 of LHC-CPP-2001 [11] .)

Configuration

See generic service options.

The ROOT Project Coding Guidelines

For the ROOT project [71] coding rules, more descriptions and clarifications are available in [70]. Note that for each of the supported ROOT project rules, the identifier for the corresponding ECLAIR service is obtained by adding the prefix UCRP1.

Rule UCRP1.RN1

Summary

Names should be chosen with care and should be meaningful. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN1 .)

Description

The names must use the specified vocabulary.

Note that the last step of the Samurai segmentation algorithm used to split names into words assumes that the names use camel-case.

Configuration

See generic service options.

Option project_dictionary
project_dictionary
-config=UCRP1.RN1,project_dictionary=PROJECT_DICT

The dictionary contains a list of words in lowercase that can be used in the project along with their frequencies (see string interpolation clause for how to specify the file).

PROJECT_DICT:

project dictionary filename.

Default:

-config=UCRP1.RN1,project_dictionary=""

Option context_dictionary
context_dictionary
-config=UCRP1.RN1,context_dictionary=CONTEXT_DICT

The dictionary contains a list of words in lowercase along with their frequencies (see string interpolation clause for how to specify the file). Note that the words and their frequencies are only used to assist the segmentation process.

CONTEXT_DICT:

context dictionary filename.

Default:

-config=UCRP1.RN1,context_dictionary=""

Option splitter_regexs
splitter_regexs
-config=UCRP1.RN1,splitter_regexs=SPLITTER,...

A list of regular expressions defining custom splitters.

{SPLITTER,…}:

set of regular expressions defining custom splitters. Accepted members are:

Default:

-config=UCRP1.RN1,splitter_regexs={}

Option segmentation_stops_after
segmentation_stops_after
-config=UCRP1.RN1,segmentation_stops_after=SAMURAI

Last step of the Samurai segmentation algorithm to be executed.

SAMURAI:

last step of the Samurai segmentation algorithm to be executed. Accepted values are:

  • none: no segmentation even on non-alpha characters;

  • underscore: segment on underscore characters;

  • non_alpha: segment on non-alpha characters;

  • lower_to_upper: segment on non-alpha and a change from lowercase to uppercase;

  • camel_case: segment on non-alpha, a change from lowercase to uppercase, and camel case;

  • no_case: segment on non-alpha, a change from lowercase to uppercase, camel case, and a score-based heuristics that is independent of any case consideration unless the word length exceeds the max-no-case-length value;

Default:

-config=UCRP1.RN1,segmentation_stops_after=camel_case

Option max_no_case_length
max_no_case_length
-config=UCRP1.RN1,max_no_case_length=MAX_LEN

The maximum length of a string upon which the “no case” step of the Samurai segmentation algorithm is applied.

MAX_LEN:

maximum string length for “no case” segmentation. It must be an integer greater than or equal to 2.

Default:

-config=UCRP1.RN1,max_no_case_length=16

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN1,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN1,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN1,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN1,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN1,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN1,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN1,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Option good_words_file
good_words_file
-config=UCRP1.RN1,good_words_file=GOOD_WORDS

A file containing a list of words, one per line, all in lowercase, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_WORDS:

good words filename.

Default:

-config=UCRP1.RN1,good_words_file=""

Option bad_words_file
bad_words_file
-config=UCRP1.RN1,bad_words_file=BAD_WORDS

A file containing a list of words, one per line, all in lowercase, that cannot be used in the project (see string interpolatn clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_WORDS:

bad words filename.

Default:

-config=UCRP1.RN1,bad_words_file=""

Option good_items_file
good_items_file
-config=UCRP1.RN1,good_items_file=GOOD_ITEMS

A file containing a list of lexical items, one per line, that can be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

GOOD_ITEMS:

good items filename.

Default:

-config=UCRP1.RN1,good_items_file=""

Option bad_items_file
bad_items_file
-config=UCRP1.RN1,bad_items_file=BAD_ITEMS

A file containing a list of lexical items, one per line, that cannot be used in the project (see string interpolation clause for how to specify the file). For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

BAD_ITEMS:

bad items filename.

Default:

-config=UCRP1.RN1,bad_items_file=""

Option good_item_regexs
good_item_regexs
-config=UCRP1.RN1,good_item_regexs=GOOD_REGEX,...

A list of regular expressions matching good identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{GOOD_REGEX,…}:

regular expressions matching good identifiers. Accepted members are:

Default:

-config=UCRP1.RN1,good_item_regexs={}

Option bad_item_regexs
bad_item_regexs
-config=UCRP1.RN1,bad_item_regexs=BAD_REGEX,...

A list of regular expressions matching bad identifiers. For a detailed description see the dedicated entry in Section The Project Vocabulary Components.

{BAD_REGEX,…}:

regular expressions matching bad identifiers. Accepted members are:

Default:

-config=UCRP1.RN1,bad_item_regexs={}

Rule UCRP1.RN2

Summary

All names must be in CamelCase except for types, that may have an additional _t suffix, and preprocessor identifiers. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN2 .)

Description

The user-defined unqualified names must be as follows:

  • type names must have one of the forms:

    • ID_t, or

    • ID;

  • all other names must have the form ID;

ID contains only letters and digits.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN2,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN2,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN2,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN2,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN2,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN2,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN2,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN3

Summary

Typedef, struct and union names begin with a capital letter and end with _t. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN3 .)

Description

typedef, struct and union names must begin with an uppercase letter and end with _t.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN3,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN3,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN3,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN3,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN3,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN3,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN3,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN4

Summary

All class names begin with T. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN4 .)

Description

class names must begin with T.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN4,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN4,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN4,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN4,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN4,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN4,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN6

Summary

Enumeration types begin with E. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN6 .)

Description

Names of enumerators must begin with E.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN6,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN6,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN6,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN6,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN6,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN6,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN7

Summary

Avoid the raw C types long, unsigned long, long double, bool, long long and unsigned long long. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN7 .)

Description

There must be no direct use of signed and unsigned variants of long, long double, bool and long long.

Configuration

See generic service options.

Option naming
naming
-config=UCRP1.RN7,naming=SCHEME,...

Specify the typedef naming schemes to be used.

The configuration’s content is a list of allowed -typedef_naming naming schemes.

SCHEME:

scheme identifier.

Default:

-config=UCRP1.RN7,naming={}

Option declarations
declarations
-config=UCRP1.RN7,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option types
types
-config=UCRP1.RN7,types={TAGS, TYPE_MATCHER},...

Specifies the report tags for types.

The configuration’s content is a list of clauses specifying the types and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

TYPE_MATCHER:

a -type_selector identifier or a matcher expression used to select types.


Rule UCRP1.RN9

Summary

Non-static data members begin with f followed by a capital letter; methods begin with a capital letter. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN9 .)

Description

Checks that

  • names of non-static data members begin with f followed by an uppercase letter;

  • names of methods begin with an uppercase letter.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN9,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN9,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN9,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN9,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN9,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN9,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN9,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN10

Summary

Global static variables begin with g. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN10 .)

Description

Names of non-const global static variables must begin with g.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN10,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN10,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN10,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN10,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN10,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN10,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN10,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN11

Summary

Static data members begin with fg. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN11 .)

Description

Names of non-const static members must begin with fg.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN11,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN11,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN11,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN11,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN11,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN11,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN11,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN12

Summary

Local (automatic and static) variables and parameters begin with a lowercase word. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN12 .)

Description

Names of local variables and function parameters must begin with a lowercase letter.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN12,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN12,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN12,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN12,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN12,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN12,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN12,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RN13

Summary

Enumeration constants, static member constants and global static constants begin with k. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RN13 .)

Description

The names of enumeration constants, static member constants and global static constants must begin with k.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=UCRP1.RN13,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=UCRP1.RN13,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=UCRP1.RN13,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=UCRP1.RN13,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=UCRP1.RN13,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=UCRP1.RN13,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=UCRP1.RN13,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule UCRP1.RS1

Summary

Do not use the <TAB> character for code layout. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RS1 .)

Description

The <TAB> character must not be used.

Configuration

See generic service options.

Rule UCRP1.RS2

Summary

The number of <SPACE> characters used for indentation shall be a multiple of 3 except for continuation lines. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RS2 .)

Description

Except for continuation lines, the number of <SPACE> characters used for indentation must be a multiple of 3.

Configuration

See generic service options.

Rule UCRP1.RS3

Summary

Every invocation of the ClassDef macro function shall be immediately followed, on the same line, by a // comment. (See http://root.cern.ch/root/nightly/codecheck/rules.html#RS3 .)

Description

Every call to the ClassDef macro function shall be immediately followed, on the same line, by a // comment.

Configuration

See generic service options.

Rule UCRP1.RS4

Summary

Descriptions of a function or class method shall be in the first comment block after the first { (i.e., it is a violation if the first non-blank newline after the opening { does not contain a comment). (See http://root.cern.ch/root/nightly/codecheck/rules.html#RS4 .)

Description

In each function or class method definition, the first non-blank line after the opening { must be a comment or the first line in a multiline comment.

Configuration

See generic service options.

Option ignored_comments
ignored_comments
-config=UCRP1.RS4,ignored_comments=COMMENT_MATCHER,...

Specify the comments that should be ignored.

The configuration’s content is a list of comment matchers.

COMMENT_MATCHER:

a -comment_selector identifier or a matcher expression used to select the comments.


Option decl_document_selector
decl_document_selector
-config=UCRP1.RS4,decl_document_selector={TAGS, CTXT, DECL, CONSTR, WHERE},...

Specifies the report tags for undocumented declarations.

The configuration’s content is list of tagged declaration and context matchers with indicators.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT:

a -context_selector identifier or a matcher expression used to select the contexts.

DECL:

a -decl_selector identifier or a matcher expression used to select the declarations.

CONSTR:

number and size constraints. Accepted forms are:

  • LIM: number or size constraint

  • LIM&&LIMS: the comments satisfy LIM and LIMS

LIM

accepted forms are:

  • num(EXPR): the minimum number of comments is specified by EXPR

  • size(EXPR): the minimum number of characters in the comments is specified by EXPR

EXPR

accepted forms are:

  • STRING: arithmetic expression whose variables are metrics

WHERE:

specifies where the explanatory comments are supposed to be found. Accepted values are:

  • begin_node: before the node;

  • end_node: after the node;

  • by_node: before or after the node on the same line;

  • by_or_within_node: before, on the same line as, within or after the node;

  • begin_body: on the line before the opening function brace;

  • begin_body_line: on line after the opening brace before the code;

  • doxygen: doxygen-style comments;


Option declarations
declarations
-config=UCRP1.RS4,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Coverage of ROOT C++ Naming and Styles Rules

The following table presents a concise summary of the coverage provided by this version of ECLAIR for the ROOT C++ naming and style rules [71]. The table adopts the following conventions:

  • The Id column contains the rule identifier. The mapping between the ROOT C++ rule and the complete ECLAIR rule identifier is one-to-one and straightforward: e.g., ROOT C++ rule RN1 is rule UCRP1.RN1 in ECLAIR.

  • Rule identifiers written in boldface font (e.g., RN1) denote required rules; rule identifiers written in normal weight font denote advisory rules.

  • The Summary column gives the rule summary.

  • The Precision column provides a short executive summary of the precision of the ECLAIR checker with respect to the rule. More precisely, that column contains:

    • Complete, when, to the best of our knowledge, the interpretation of the rule given in the ECLAIR manual is what is implemented by the checker and every possible non-compliance is reported.

    • Heuristic, when the checker for an undecidable rule uses a heuristic aimed at reducing the number of false alarms.

    • Best-effort, when the checker does not report all the non-compliances of the rule, when the rule is interpreted as explained in the ECLAIR manual.

    • Process, when the rule does not ask for specific results but for the adoption of means and/or processes.

    Note that every violation report is sound, while caution reports should be checked by user for correctness.

    For non-exact checkers, a hint about the reason for the imprecision is also given: do refer to the detailed rule descriptions for a proper treatment of the matter.

UCRP1 synopsis: supported ROOT C++ rules

Id

Summary

Precision

UCRP1.RN1

Names should be chosen with care and should be meaningful

Process

UCRP1.RN2

All names must be in CamelCase except for types, that may have an additional _t suffix, and preprocessor identifiers

Exact

UCRP1.RN3

Typedef, struct and union names begin with a capital letter and end with _t

Exact

UCRP1.RN4

All class names begin with T

Exact

UCRP1.RN6

Enumeration types begin with E

Exact

UCRP1.RN7

Avoid the raw C types long, unsigned long, long double, bool, long long and unsigned long long

Exact

UCRP1.RN9

Non-static data members begin with f followed by a capital letter; methods begin with a capital letter

Exact

UCRP1.RN10

Global static variables begin with g

Exact

UCRP1.RN11

Static data members begin with fg

Exact

UCRP1.RN12

Local (automatic and static) variables and parameters begin with a lowercase word

Exact

UCRP1.RN13

Enumeration constants, static member constants and global static constants begin with k

Exact

UCRP1.RS1

Do not use the <TAB> character for code layout

Exact

UCRP1.RS2

The number of <SPACE> characters used for indentation shall be a multiple of 3 except for continuation lines

Exact

UCRP1.RS3

Every invocation of the ClassDef macro function shall be immediately followed, on the same line, by a // comment

Exact

UCRP1.RS4

Descriptions of a function or class method shall be in the first comment block after the first { (i.e., it is a violation if the first non-blank newline after the opening { does not contain a comment)

Exact

The VVSGP1 Rules

Rule VVSGP1.5.2.5.a

Summary

Application logic shall handle exceptions using block-structured exception handling constructs. (See page 115 of VVSG-1-1.1-2015 [72] .)

Description

Calls to standard library functions whose return values contain error information are always checked.

To specify functions not in the standard library that return error information use the -call_properties global configuration with property error.

An error-returning function call is compliant if any of the following hold.

  • The returned value is tested directly and the result of the test is used.

  • The returned value is returned directly to the calling function which must have a similar error value expectation (that is, with the same error configuration).

  • The returned value is stored in a variable and that variable is tested in a statement that immediately follows the call in one of the following ways:

    • the test is in the condition part of an if statement;

    • the variable is in the condition expression of a switch statement, and the case and default labels select the specified error values;

    • it is a return statement that returns the result of the test.

The errno must be set to 0 immediately before the call.

Configuration

See generic service options.

Option calls
calls
-config=VVSGP1.5.2.5.a,calls={TAGS, CTXT_MATCHER, CALL_MATCHER},...

Specifies the report tags for calls.

The configuration’s content is a list of clauses specifying the calls and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

CTXT_MATCHER:

a -context_selector identifier or a matcher expression used to select the call contexts.

CALL_MATCHER:

a -call_selector identifier or a matcher expression used to select the calls.


Option handling
handling
-config=VVSGP1.5.2.5.a,handling={DECL_MATCHER, ID, SLCT, {{TAG, ACTION, FMT},...}},...

Specify the error handling.

The configuration’s content is an ordered list of a declaration matcher for the calling function, an error identifier and associated data about where the error is placed, where it should be tested and what actions should be taken.

Note that the first matching clause for the calling function and error identifier will be selected and the error value is checked using the associated data

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.

ID:

an identifier declared in the -function_error global configuration.

SLCT:

specifies if handling is in a switch or if statement. Accepted values are:

  • any: any selection;

  • if: if statement;

  • switch: switch statement;

TAG:

a value tag declared in the -function_error global configuration.

ACTION:

action to be taken at end of related error branch. Accepted forms are:

  • any: the action is not checked

  • return_any(): the action is to return

  • return(RETURN_VAL): the action is to return RETURN_VAL

  • return_minus(RETURN_VAL): the action is to return the negated RETURN_VAL

  • return_call(CALL_MATCHER,RETURN_VAL): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression) where the RETURN_VAL is an argument to the call; the called function must have a noreturn attribute (see the -decl_properties global configuration)

  • goto(REGEX): the action is a goto statement with label matching REGEX

  • throw(TYPE_MATCHER): the action is a throw statement with type matching TYPE_MATCHER (see the -type_selector global configuration)

  • call(CALL_MATCHER): the action is a call matching CALL_MATCHER (a -call_selector identifier or a call matcher expression)

  • switch(FUNCTION_ERROR): the action is a switch statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

  • if(FUNCTION_ERROR): the action is an if statement with checks that match those specified by FUNCTION_ERROR (see the -function_error global configuration); the select kind for this handling must be an if statement

REGEX

accepted forms are:

RETURN_VAL

accepted forms are:

  • return_value(): the returned value

  • INTEGER: the value

  • STMT_MATCHER: a sub-expression of an expression matching STMT_MATCHER (see the -stmt_selector global configuration)

FMT:

format (see the -fmt template callpost__default_fmt) to specify the message describing ACTION.

Default:

-config=VVSGP1.5.2.5.a,handling={}

Examples for VVSGP1.5.2.5.a
  1. the example shows a configuration and compliant code that uses a switch to select and act on the errno values EPERM and EBUSY when the return value for open() is less that or equal to 0.

-function_error+=
 {id1,"__errno_stmts","",{{tag1,"macro(^EBUSY$)", ""},{tag2,"macro(^EPERM$)", ""}}}
-config=VVSGP1.5.2.5.a,handling+=
 {"any()",id1,switch,{{tag1,"goto(^retry$)", ""},{tag2,"goto(^error$)", ""}}}
-function_error+= {id0,return_value,"",{{tag0,"in(..-1)", ""}}}
-config=VVSGP1.5.2.5.a,call+= "^open\\(.*\\)$"
-config=VVSGP1.5.2.5.a,handling+= {"any()",id0,if, {{tag0, "switch(id1)", ""}}}

-call_properties+={"^open\\(.*\\)$", {"error(id0)"}}
  var = open("file1", O_WRONLY); /* compliant */
  if (var < 0) {
     switch (errno) {
     case EBUSY: goto retry;
     case EPERM: goto error;
     }
  }
 retry: return;
 error: return;
  1. the example uses the same configuration as example 1, but the code is non-compliant as it fails to check for the error value EPERM.

-function_error+=
 {id1,"__errno_stmts","",{{tag1,"macro(^EBUSY$)", ""},{tag2,"macro(^EPERM$)", ""}}}
-config=VVSGP1.5.2.5.a,handling+=
 {"any()",id1,switch,{{tag1,"goto(^retry$)", ""},{tag2,"goto(^error$)", ""}}}
-function_error+= {id0,return_value,"",{{tag0,"in(..-1)", ""}}}
-call_properties+={"^open\\(.*\\)$", {"error(id0)"}}
-config=VVSGP1.5.2.5.a,call+= "^open\\(.*\\)$"
-config=VVSGP1.5.2.5.a,handling+= {"any()",id0,if, {{tag0, "switch(id1)", ""}}}

  var = open("file1", O_WRONLY); /* non-compliant */
  if (var < 0) {
     switch (errno) {
     case EBUSY: goto retry;
     default: goto retry;
     }
  }
 retry: return;
 error: return;
ex02.cc:1.9-1.12: violation for rule VVSGP1.5.2.5.a (Application logic 
shall handle exceptions using block-structured exception handling 
constructs.) Loc #1 [culprit: the error value for call to function 
`open(const char*, int, ...)' does not check all error values]
  var = open("file1", O_WRONLY); /* non-compliant */
        <~~>
ex02.cc:3.6-3.11: Loc #2 [evidence: the `switch' statement has no matching 
branch for error values for tag `tag2']
     switch (errno) {
     <~~~~>
  1. the example shows a configuration that checks the function open() with the requirement that the return value must be checked for the error value -1, throwing an object of type runtime_error if the test is successful.

-type_selector={__except, 'desugar(record_kind(class)&&^(.*::)?runtime_error$)'}

-function_error+={id1, return_value, "", {{tag1, "in(-1)", ""}}}
-config=VVSGP1.5.2.5.a,call+="^open\\(.*\\)$"
-config=VVSGP1.5.2.5.a,handling+=
  {"any()", id1, any, {{tag1, "throw(__except)", ""}}}

-call_properties+={"^open\\(.*\\)$", {"error(id1)"}}
  variable = open("abc", 0);
if (variable == -1) //compliant
    throw std::runtime_error(std::string("open: ") + strerror(errno));
  1. the example shows a configuration that checks the function open() with the requirement that the return value must be checked for negative values, throwing an object of type runtime_error if the test is successful.

-type_selector={__except, 'desugar(record_kind(class)&&^(.*::)?runtime_error$)'}

-function_error+={id1, return_value, "", {{tag1, "in(..-1)", ""}}}
-config=VVSGP1.5.2.5.a,call+="^open\\(.*\\)$"
-config=VVSGP1.5.2.5.a,handling+=
  {"any()", id1, any, {{tag1, "throw(__except)", ""}}}

-call_properties+={"^open\\(.*\\)$", {"error(id1)"}}
  variable = open("abc", 0);
  if (variable < 0) //compliant
    throw std::runtime_error(std::string("open: ") + strerror(errno));
  1. the example uses the same configuration as in example 3 with compliant code that negates the error value to select the else branch to act on an error.

-type_selector={__except, 'desugar(record_kind(class)&&^(.*::)?runtime_error$)'}

-function_error+={id1, return_value, "", {{tag1, "in(-1)", ""}}}
-config=VVSGP1.5.2.5.a,call+="^open\\(.*\\)$"
-config=VVSGP1.5.2.5.a,handling+=
  {"any()", id1, any, {{tag1, "throw(__except)", ""}}}

-call_properties+={"^open\\(.*\\)$", {"error(id1)"}}
  variable = open("abc", 0);
  if (variable != -1)
    return 0;
  else
    throw std::runtime_error(std::string("open: ") + strerror(errno));
  1. the example uses the same configuration as in example 3 with code that is non-compliant, as the returned value is stored in an unsigned int, so that negative values are checked incorrectly.

-type_selector={__except, 'desugar(record_kind(class)&&^(.*::)?runtime_error$)'}

-function_error+={id1, return_value, "", {{tag1, "in(-1)", ""}}}
-config=VVSGP1.5.2.5.a,call+="^open\\(.*\\)$"
-config=VVSGP1.5.2.5.a,handling+=
  {"any()", id1, any, {{tag1, "throw(__except)", ""}}}

-call_properties+={"^open\\(.*\\)$", {"error(id1)"}}
  unsigned variable;
  variable = open("abc", 0); // non-compliant
  if (variable == -1)
    throw std::runtime_error(std::string("open: ") + strerror(errno));
ex06.cc:2.14-2.17: violation for rule VVSGP1.5.2.5.a (Application logic 
shall handle exceptions using block-structured exception handling 
constructs.) Loc #1 [culprit: the error value for call to function 
`open(const char*, int, ...)' with return type `int' is assigned to 
variable `variable']
  variable = open("abc", 0); // non-compliant
             <~~>
ex06.cc:1.12-1.19: Loc #2 [evidence: variable `variable' has type 
`unsigned']
  unsigned variable;
           <~~~~~~>
  1. the example uses the same configuration as in example 3 with code that is non-compliant, as the throw expression has type int.

-type_selector={__except, 'desugar(record_kind(class)&&^(.*::)?runtime_error$)'}

-function_error+={id1, return_value, "", {{tag1, "in(-1)", ""}}}
-config=VVSGP1.5.2.5.a,call+="^open\\(.*\\)$"
-config=VVSGP1.5.2.5.a,handling+=
  {"any()", id1, any, {{tag1, "throw(__except)", ""}}}

-call_properties+={"^open\\(.*\\)$", {"error(id1)"}}
  variable = open("abc", 0);
if (variable == -1) //compliant
    throw errno;
ex07.cc:1.14-1.17: violation for rule VVSGP1.5.2.5.a (Application logic 
shall handle exceptions using block-structured exception handling 
constructs.) Loc #1 [culprit: for call to function `open(const char*, int, 
...)', the error values for tag `tag1' are tested but the `throw' action 
with expression of type `int' is non-compliant]
  variable = open("abc", 0);
             <~~>
ex07.cc:3.5-3.9: Loc #2 [evidence: non-compliant `throw' expression]
    throw errno;
    <~~~>

Rule VVSGP1.5.2.6

Summary

Application logic modules should include header comments that provide the required information for each callable unit. (See page 116 of VVSG-1-1.1-2015 [72] .)

Configuration

See generic service options.

Option grammar
grammar
-config=VVSGP1.5.2.6,grammar={ID, {ACTION,...}},...

Specify the grammar clauses.

The configuration’s content is a list of grammar clauses associated to non-terminals.

ID:

the non-terminal identifier.

ACTION:

the action specifier text and the destination of related value. Accepted forms are:

  • OPT_DESTSOPT_NUM^REGEX$: the text should match ^REGEX$, the consumed text ends at group OPT_NUM (default 0), matched groups are assigned to OPT_DESTS

  • DEST:STRING: the string STRING is assigned to DEST

  • OPT_DESTSIDOPT_CALL_ARGS: the nonterm or builtin ID is called with arguments specified in OPT_CALL_ARGS, the returned value is assigned to OPT_DESTS

REGEX

accepted forms are:

Default:

-config=VVSGP1.5.2.6,grammar={function, {"^/\\*!(?=\\s)", "@data=[]", "@msgs=[]", "commands()", "@checks=[['missing','brief','sideeffects','protocols','date','audit','version',['global','noglobals'],['fileaccess','nofileaccesses']],['repeated','brief','details','return','noglobals','nofileaccesses',['global','noglobals'],['fileaccess','nofileaccesses']],['return','return'],['param','param'],['global','global'],['throw','exception']]"}}, {commands, {"^(?s:.)*?\\R\\s*\\\\", "@ofs=_offset()", "command()", "commands()"}}, {commands, {"^(?s:.)*\\z"}}, {command, {"[@cmd]=^(brief|details|return|sideeffects|protocols|date|audit|version)(?=[^a-z])", "paragraph()", "@data=_cons([@cmd,@ofs],@data)"}}, {command, {"[@cmd]=^(noglobals|nofileaccesses)(?=[^a-z])", "empty()", "@data=_cons([@cmd,@ofs],@data)"}}, {command, {"[@cmd]=^(global|endglobals|fileaccess|endfileaccesses)(?=[^a-z_])", "text='unexpected command '", "@msgs=_cons([@ofs,text,@cmd],@msgs)"}}, {command, {"[@cmd]=^(param)(?=[^a-z_])", "param()"}}, {command, {"[@cmd]=^(exception)\\s+", "exception()"}}, {command, {"^globals(?=[^a-z_])", "globals()"}}, {command, {"^fileaccesses(?=[^a-z_])", "fileaccesses()"}}, {command, {}}, {exception, {"type=type()", "paragraph()", "@data=_cons([@cmd,type,@ofs],@data)"}}, {exception, {"text='malformed \\exception'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {direction, {"[@]=^\\s*\\[(in|out|inout)]"}}, {direction, {"ofs=_offset()", "^\\s*\\[[^]]*]", "text='invalid direction'", "@msgs=_cons([ofs,text],@msgs)", "@=''"}}, {param, {"dir=direction()", "^\\s+", "id=id()", "paragraph()", "@data=_cons([@cmd,id,dir,@ofs],@data)"}}, {param, {"text='malformed \\param'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {arg_direction, {"[@]=^\\[(in|out)]"}}, {arg_direction, {"^\\[in\\\\,out]", "@='inout'"}}, {arg_direction, {"ofs=_offset()", "^\\[[^]]*]", "text='invalid direction'", "@msgs=_cons([ofs,text],@msgs)", "@=''"}}, {globals, {"^(?:\\R)+\\h*\\\\", "@ofs=_offset()", "[@cmd]=^(global)(?=[^a-z_])", "global()", "globals()"}}, {globals, {"^(?:\\R)+\\h*\\\\endglobals"}}, {globals, {"text='malformed \\globals group'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {global, {"^\\s*{\\s*", "dir=arg_direction()", "^\\s*,\\s*", "qualid=arg_qualid()", "^\\s*,\\s*", "arg()", "^\\s*}", "@data=_cons([@cmd,qualid,dir,@ofs],@data)"}}, {global, {"text='malformed \\global'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {fileaccesses, {"^(?:\\R)+\\h*\\\\", "@ofs=_offset()", "[@cmd]=^(fileaccess)(?=[^a-z_])", "fileaccess()", "fileaccesses()"}}, {fileaccesses, {"^(?:\\R)+\\h*\\\\endfileaccesses"}}, {fileaccesses, {"text='malformed \\fileaccesses group'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {fileaccess, {"^\\s*{\\s*", "dir=arg_direction()", "^\\s*,\\s*", "file=arg_file()", "^\\s*,\\s*", "arg()", "^\\s*}", "@data=_cons([@cmd,file,dir,@ofs],@data)"}}, {fileaccess, {"text='malformed \\fileaccess'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {empty, {"^\\s*(?=\\R|\\*/)"}}, {empty, {"text='unexpected text after command '", "ofs=_offset()", "@msgs=_cons([ofs,text,@cmd],@msgs)"}}, {paragraph, {"^(?s:.)*?\\S(?s:.)*?(?=\\R\\R|\\v\\s*\\\\(?:attention|authors?|brief|bug|cond|copyright|date|deprecated|else|elseif|endcond|endif|exception|if|ifnot|invariant|note|par|param|parblock|post|pre|remarks?|result|returns?|retval|sa|see|short|since|test|throws?|todo|tparam|version|warning|xrefitem|sideeffects|protocols|audit|globals|noglobals|fileaccesses|nofileaccesses)[^a-z_]|\\*/)"}}, {paragraph, {"text='expected paragraph after command '", "ofs=_offset()", "@msgs=_cons([ofs,text,@cmd],@msgs)"}}, {id, {"[@]=^([_a-zA-Z][_a-zA-Z0-9]*)"}}, {id, {"text='invalid identifier'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {arg, {"[@]=^([^\\\\,}]*(?:\\\\.[^\\\\,}]*)*)"}}, {arg_file, {"[@]=^([^\\\\ ,}]*(?:\\\\.[^\\\\ ,}]*)*)"}}, {arg_qualid, {"[@]=^([_a-zA-Z][_a-zA-Z0-9]*)(?::[_a-zA-Z][_a-zA-Z0-9]*)*"}}, {arg_qualid, {"text='invalid qualified identifier'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}, {type, {"[@]=^(\\S*)"}}, {type, {"text='invalid type'", "ofs=_offset()", "@msgs=_cons([ofs,text],@msgs)"}}

Option declarations
declarations
-config=VVSGP1.5.2.6,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


The ZIND Rules

Rule ZIND.107

Summary

Local variable names should begin with a lowercase letter.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=ZIND.107,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=ZIND.107,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=ZIND.107,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=ZIND.107,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=ZIND.107,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=ZIND.107,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=ZIND.107,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule ZIND.108

Summary

Global variable names should begin with an uppercase letter.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=ZIND.108,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=ZIND.108,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=ZIND.108,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=ZIND.108,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=ZIND.108,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=ZIND.108,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=ZIND.108,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule ZIND.109

Summary

Function names should begin with an uppercase letter.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=ZIND.109,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=ZIND.109,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=ZIND.109,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=ZIND.109,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=ZIND.109,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=ZIND.109,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=ZIND.109,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule ZIND.112

Summary

Macro names should be composed by uppercase letters and underscores.

Configuration

See generic service options.

Option misnamed_entity_fmt
misnamed_entity_fmt
-config=ZIND.112,misnamed_entity_fmt={TAG, ENTITY_MATCHER, NAME_MATCHER, FMT},...

Specify entities and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of entity and misnaming matchers with message format; the hide-show tag and message format are associated with the first matching entity and name.

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

entity description;

name

unqualified identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ''.


Option misnamed_macro_fmt
misnamed_macro_fmt
-config=ZIND.112,misnamed_macro_fmt={TAG, MACRO_MATCHER, NAME_MATCHER, KIND, FMT},...

Specify macro and the misnaming matcher to be shown using a short-circuit sequence with message format.

The configuration’s content is an ordered tagged list of macro, name matcher, name-flag indicating if the macro name or the parameter names should be matched, and a message format; the hide-show tag is associated with the first matching macro and macro or parameter names (depending on the name-flag).

TAG:

a tag with values hide and show. Accepted values are:

  • hide: hide if it matches the associated conditions;

  • show: show if it matches the associated conditions;

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;

FMT:

format (see the -fmt global configuration content, template enttname__default_fmt) with fields:

node

macro or macro parameter;

name

the identifier;

kind

entity kind;

name_info_tag

tag returned by name matcher;

vocab_msg

vocabulary error message or ‘’.


Option misnamed_entity
misnamed_entity
-config=ZIND.112,misnamed_entity={ENTITY_MATCHER, NAME_MATCHER},...

Specify the entity and name matchers.

The configuration’s content is an ordered tagged list of entity and misnaming matchers; the hide-show tag is associated with the first matching entity and name.

ENTITY_MATCHER:

a -entity_selector identifier or a matcher expression used to select the entities.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.


Option misnamed_macro
misnamed_macro
-config=ZIND.112,misnamed_macro={MACRO_MATCHER, NAME_MATCHER, KIND},...

Specify the macro and name matchers.

The configuration’s content is an ordered tagged list of macro, name matcher and name-flag indicating if the macro name or the parameter names should be matched; the hide-show tag is associated with the first matching macro and name(s).

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.

NAME_MATCHER:

a -name_selector identifier or a matcher expression used to select the names.

KIND:

whether to check macro or macro parameters. Accepted values are:

  • macro: macro name;

  • param: macro parameter;

  • any: macro name or macro parameters;


Option declarations
declarations
-config=ZIND.112,declarations={TAGS, DECL_MATCHER},...

Specifies the report tags for declarations.

The configuration’s content is a list of clauses specifying the declarations and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

DECL_MATCHER:

a -decl_selector identifier or a matcher expression used to select the declarations.


Option macros
macros
-config=ZIND.112,macros={TAGS, MACRO_MATCHER},...

Specifies the report tags for macros.

The configuration’s content is a list of clauses specifying the macros and related report tags.

TAGS:

a possibly empty sequence of report tags separated by +. Notes:

  • A report tag or rtag can have one of two forms:

    • Domain:Tag_Name where Domain is a tag domain and Tag_Name is a tag in Domain,

    • Tag_Name where Tag_Name is a tag in the domain tag;

  • the tag missing is reserved as a default tag; a report that has no specified tag in a domain Domain is given the tag missing for Domain;

  • if the special tag hide (after any remapping) is applicable to a report, then that report will be hidden;

  • tags (including hide) can be remapped to other tags using the -remap_rtag global configuration.

MACRO_MATCHER:

a -macro_selector identifier or a matcher expression used to select the macros.


Option all_decls
all_decls
-config=ZIND.112,all_decls=BOOL

Specify whether to show all or just a single representative declaration for each reported entity.

BOOL:

boolean indicating whether to show one or all declarations. Accepted values are:

  • true: show all declarations for each reported entity;

  • false: show a representative declaration for each reported entity;


Rule ZIND.117

Summary

For each *.c file there must exist a *.h file with the same name containing the declarations to be exported to other modules.

Configuration

See generic service options.

Rule ZIND.119

Summary

Each *.c file should directly include the *.h file with the same name.

Description

The main file NAME.c must include the header file NAME.h.

Configuration

See generic service options.

Undefined Behaviors for the ISO C language

The following sections contain the text of each numbered undefined behavior for each of the corresponding ISO C standards [34, 37, 40, 43] as indicated in Appendix H of MISRA C.

C90 undefined behaviours

  1. A nonempty source file does not end in a new-line character, ends in new-line character immediately preceded by a backslash character, or ends in a partial preprocessing token or comment (5.1.1.2).

  1. A character not in the required character set is encountered in a source file. except in a preprocessing token that is never converted to a token. a character constant. a string literal. a header name. or a comment (5.2.1).

  1. A comment. string literal. character constant, or header name contains an invalid multibyte character or does not begin and end in the initial shift state (5.2.1.2).

  1. The same identifier is used more than once as a label in the same function (6.1.2.1).

  1. An identifier is used that is not visible in the current scope (6.1.2.1).

  1. The same identifier has both internal and external linkage in the same translation unit (6.2.2).

  1. The value stored in a pointer that referred to an object with automatic storage duration is used (6.1.2.4)

  1. Two declarations of the same object or function specify types that are not compatible (6.1.2.6).

  1. An arithmetic conversion produces a result that cannot be represented in the space provided (6.2. I ).

  1. An lvalue with an incomplete type is used in a context that requires the value of the designated object (6.2.2.1).

  1. The value of a void expression is used or an implicit conversion (except to void) is applied to a void expression (6 2.2.2).

  1. A pointer to a function is converted to point to a function of a different type and used to call a function of a type not compatible with the original type (6.3.4).

  1. An unmatched ‘ or “ character is encountered on a logical source line during tokenization (6.1)

  1. Identifiers that are intended to denote the same entity differ in a character beyond the minimal significant characters (6.1.2).

  1. An unspecified escape sequence is encountered in a character constant or a string literal (6.1.3.4).

  1. An attempt is made to modify a string literal of either form (6.1.4).

  1. A character string literal token is adjacent to a wide string literal token (6. I .4).

  1. The characters ‘ . , “, or /* are encountered between the < and > delimiters or the characters ‘, , or /* are encountered between the “ delimiters in the two forms of a header name preprocessing token (6. I .7).

  1. An object is moditied more than once. or is modified and accessed other than to determine the new value. between two sequence points (6.3)

  1. An arithmetic operation is invalid (such as division or modulus by 0) or produces a result that cannot be represented in the space provided (such as overflow or underflow) (6.3)

  1. An object has its stored value accessed by an lvalue that does not have one of the following types: the declared type of the object, a qualified version of the declared type of the object, the signed or unsigned type corresponding to the declared type of the object. the signed or unsigned type corresponding to a qualified version of the declared type of the object. an aggregate or union type that (recursively) includes one of the aforementioned types among its members. or a character type (6.3)

  1. An argument to a function is a void expression (6.3.2.2)

  1. For a function call without a function prototype. the number of arguments does not agree with the number of parameters (6.3.2.2)

  1. For a function call without a function prototype, if the function is defined without a function prototype, and the types of the arguments after promotion do not agree with those of the parameters after promotion (6.3.2.2).

  1. If a function is called with a function prototype and the function is not defined with a compatible type (6.3.2.2)

  1. A function that accepts a variable number of arguments is called without a function prototype that ends with an ellipsis (6.3.2.2).

  1. An invalid array reference, null pointer reference. or reference to an object declared with automatic storage duration in a terminated block occurs (6.3.3.2).

  1. A pointer to a function is converted to a pointer to an object or a pointer to an object is converted to a pointer to a function (6.3.4).

  1. A pointer is converted to other than an integral or pointer type (6.3.4).

  1. A pointer that does not behave like a pointer to an element of an array object is added to or subtracted from (6.3.6).

  1. Pointers that do not behave as if they point to the same array object are subtracted (6.3.6).

  1. An expression is shifted by a negative number or by an amount greater than or equal to the width in bits of the expression being shifted (6.3.7):

  1. Pointers are compared using a relational operator that do not point to the same aggregate or union (6.3.8).

  1. An object is assigned to an overlapping object (6.3.16.1).

  1. An identifier for an object is declared with no linkage and the type of the object is incomplete after its declarator, or after its init-declarator if it has an initializer (6.5).

  1. A function is declared at block scope with a storage-class specifier other than extern (6.5.1)

  1. A structure or union is defined as containing only unnamed members (6.5.2.1).

  1. A bit-field is declared with a type other than int, signed int, or unsigned int (6.5.2.1).

  1. An attempt is made to modify an object with const-qualified type by means of an lvalue with non- const-qualified type (6.5.3).

  1. An attempt is made to refer to an object with volatile-qualified type by means of an lvalue with non-volatile-qualified type (6.5.3)

  1. The value of an uninitialized object that has automatic storage duration is used before a value is assigned (6.5.7)

  1. An object with aggregate or union type with static storage duration has a non-brace-enclosed initializer. or an object with aggregate or union type with automatic storage duration has either a single expression initializer with a type other than that of the object or a non-brace-enclosed initializer (6.5.7).

  1. An identifier with external linkage is used but there does not exist exactly one external definition in the program for the identifier (6.7).

  1. A function that accepts a variable number of arguments is defined without a parameter type list that ends with the ellipsis notation (6 7.1)

  1. The value of a function is used. but no value was returned (6.6.6.4).

  1. An identifier for an object with internal linkage and an incomplete type is declared with a tentative definition (6.7.2).

  1. The token defined is generated during the expansion of a #if or #elif preprocessing directive (6.8.1).

  1. The #include preprocessing directive that results after expansion does not match one of the two header name forms (6.8.2).

  1. A macro argument consists of no preprocessing tokens (6.8.3).

  1. There are sequences of preprocessing tokens within the list of macro arguments that would otherwise act as preprocessing directive lines (6.8.3).

  1. The result of the preprocessing operator # is not a valid character string literal (6.8.3.2).

  1. The result of the preprocessing concatenation operator ## is not a valid preprocessing token (6.8.3.3).

  1. The #line preprocessing directive that results after expansion does not match one of the two well-defined forms (6.8.4).

  1. One of the following identifiers is the subject of a #define or #undef preprocessing directive defined __LINE__ __FILE__ __DATE__ __TIME__ or __STDC__ (6.8.8).

  1. An attempt is made to copy an object to an overlapping object by use of a library function other than memmove (clause 7).

  1. The effect if a standard header is included within an external definition; is included for the first time after the first reference to any of the functions or objects it declares, or to any of the types or macros it defines; or is included while a macro is defined with a name the same as a keyword (7.1.2).

  1. The effect if the program redefines a reserved external identifier (7.1.3).

  1. A library function argument has an invalid value, unless the behaviour is specified explicitly (7.1.7).

  1. A library function that accepts a variable number of arguments is not declared (7.1.7).

  1. The macro definition of assert is suppressed to obtain access to an actual function (7.2).

  1. The argument to a character handling function is out of the domain (7.3).

  1. A macro definition of errno is suppressed to obtain access to an actual object (7.1.4).

  1. The result of converting a string to a number by the atof, atoi, or atol function cannot be represented (7.10.1).

  1. The result of an integer arithmetic function (abs. div, labs, or ldiv) cannot be represented (7.10.6).

  1. A macro definition of setjmp is suppressed to obtain access to an actual function (7.6).

  1. An invocation of the setjmp macro occurs in a context other than as the controlling expression in a selection or iteration statement. or in a comparison with an integral constant expression (possibly as Implied by the unary ! operator) as the controlling expression of a selection or iteration statement. or as an expression statement (possibly cast to void) (7.6.1.1).

  1. An object of automatic storage class that does not have volatile-qualified type has been changed between a setjmp invocation and a longjmp call and then has its value accessed (7 6.3.1)

  1. The longjmp function is invoked from a nested signal routine (7.6.2.1).

  1. A signal occurs other than as the result of calling the abort or raise function. and the signal handler calls any function in the standard library other than the signal function itself or refers to any object with static storage duration other than by assigning a value to a static storage duration variable of type volatile sig_atomic_t (7.7.1 I)

  1. The value of errno is referred to after a signal occurs other than as the result of calling the abort or raise function and the corresponding signal handler calls the signal function such that it returns the value SIG_ERR (7.7.1.1 ).

  1. The macro va_arg is invoked with the parameter ap that was passed to a function that invoked the macro va_arg with the same parameter (7.8).

  1. A macro definition of va_start, va_arg, or va_end or a combination thereof is suppressed to obtain access to an actual function (7.8.1).

  1. The va_end macro is invoked without a corresponding invocation of the va_start macro (7.8.1.3).

  1. A return occurs from a function with a variable argument list initialized by the va_start macro before the va_end macro is invoked (7.8.1.3).

  1. There is no actual next argument for a va_arg macro invocation (7.8.1.2).

  1. The type of the actual next argument in a variable argument list disagrees with the type specified by the va_arg macro (7.8.1.2).

  1. The parameter parmN of a va_start macro is declared with the register storage class, or with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions (7.8.1.1).

  1. The parameter member-designator of an offsetof macro is an invalid right operand to the . operator for the type parameter or designates bit-field member of a structure (7.1.6).

  1. The stream for the fflush function points to an input stream or to an update stream in which the most recent operation was input (7.9.5.2).

  1. An output operation of an update stream is followed by an input operation without an intervening call to the fflush function or a file positioning function, or an input operation on an update stream is followed by an output operation without an intervening call to a file positioning function (7.9.5.3).

  1. The format for the fprintf or fscanf function does not match the argument list (7.9.6).

  1. An aggregate or union, or a pointer to an aggregate or union is an argument to the fprintf function, except for the conversion specifiers %s (for an array of character type) or %p (for a pointer to void) (7.9.6.I)

  1. A conversion specification for the fprintf function contains a # flag with a conversion specifier other than o, x, X, e, E, f, g, or G (7.9.6.I)

  1. A conversion specification for the fprintf function contains a 0 flag with a conversion specifier other than d, i, o, u, x, X, e, E, f, g, or G (7.9.6.I)

  1. A %% conversion specification for the fprintf or fscanf function contains characters between the pair of % characters (7.9.6).

  1. A conversion specification for the fscanf function contains an h or l with a conversion specifier other than d, i, n, o, u, or x, or an L with a conversion specifier other than e, f, or g (7.9.6.3)

  1. A %% conversion specification for the fprintf or fscanf function contains characters between the pair of % characters (7.9.6).

  1. An invalid conversion specification is found in the format for the strftime function (7.12.3.5).

  1. An invalid conversion specification is found in the format for the fprintf or fscanf function (7.9.6).

  1. A single conversion by the fprintf function produces more than 509 characters of output (7.9.6.1)

  1. The result of a conversion by the fscanf function cannot be represented in the space provided. or the receiving object does not have an appropriate type (7.9.6.2).

  1. A pointer value printed by %p conversion by the fprintf function during a previous program execution is the argument for %p conversion by the fscanf function (7.9.6.2).

  1. The value of a pointer that refers to space deallocated by a call to the free or realloc function is referred to (7.10.3).

  1. The pointer argument to the free or realloc function does not match a pointer earlier returned by calloc, malloc, or realloc, or the object pointed to has been deallocated by a call to free or realloc (7.10.3).

  1. A program executes more than one call to the exit function (7.10.4.3).

  1. The shift states for the mblen, mbtowc, and wctomb functions are not explicitly reset to the initial state when the LC_CTYPE category of the current locale is changed (7.10.7).

  1. An array written to by a copying or concatenation function is too small (7.11.2, 7.11.3).

C99 undefined behaviours

  1. A “shall” or “shall not” requirement that appears outside of a constraint is violated (clause 4).

  1. A nonempty source file does not end in a new-line character which is not immediately preceded by a backslash character or ends in a partial preprocessing token or comment (5.1.1.2).

  1. Token concatenation produces a character sequence matching the syntax of a universal character name (5.1.1.2)

  1. A program in a hosted environment does not define a function named main using one of the specified forms (5.1.2.2.1)

  1. A character not in the basic source character set is encountered in a source file, except in an identifier, a character constant, a string literal, a header name, a comment, or a preprocessing token that is never converted to a token (5.2.1).

  1. An identifier, comment, string literal, character constant, or header name contains an invalid multibyte character or does not begin and end in the initial shift state (5.2.1.2).

  1. The same identifier has both internal and external linkage in the same translation unit (6.2.2).

  1. An object is referred to outside of its lifetime (6.2.4).

  1. The value of a pointer to an object whose lifetime has ended is used (6.2.4).

  1. The value of an object with automatic storage duration is used while it is indeterminate (6.2.4, 6.7.8, 6.8).

  1. A trap representation is read by an lvalue expression that does not have character type (6.2.6.1).

  1. A trap representation is produced by a side effect that modifies any part of the object using an lvalue expression that does not have character type (6.2.6.1).

  1. The arguments to certain operators are such that could produce a negative zero result, but the implementation does not support negative zeros (6.2.6.2).

  1. Two declarations of the same object or function specify types that are not compatible (6.2.7).

  1. Conversion to or from an integer type produces a value outside the range that can be represented (6.3.1.4).

  1. Demotion of one real floating type to another produces a value outside the range that can be represented (6.3.1.5).

  1. An lvalue does not designate an object when evaluated (6.3.2.1).

  1. A non-array lvalue with an incomplete type is used in a context that requires the value of the designated object (6.3.2.1).

  1. An lvalue having array type is converted to a pointer to the initial element of the array, and the array object has register storage class (6.3.2.1).

  1. An attempt is made to use the value of a void expression, or an implicit or explicit conversion (except to void) is applied to a void expression (6.3.2.2).

  1. Conversion of a pointer to an integer type produces a value outside the range that can be represented (6.3.2.3).

  1. Conversion between two pointer types produces a result that is incorrectly aligned (6.3.2.3).

  1. A pointer is used to call a function whose type is not compatible with the pointed-to type (6.3.2.3).

  1. An unmatched ‘ or “ character is encountered on a logical source line during tokenization (6.4).

  1. A reserved keyword token is used in translation phase 7 or 8 for some purpose other than as a keyword (6.4.1).

  1. A universal character name in an identifier does not designate a character whose encoding falls into one of the specified ranges (6.4.2.1).

  1. The initial character of an identifier is a universal character name designating a digit (6.4.2.1).

  1. Two identifiers differ only in nonsignificant characters (6.4.2.1).

  1. The identifier _ _func_ _ is explicitly declared (6.4.2.2).

  1. The program attempts to modify a string literal (6.4.5).

  1. The characters ‘, , “, //, or /* occur in the sequence between the < and > delimiters, or the characters ‘, , //, or /* occur in the sequence between the “ delimiters, in a header name preprocessing token (6.4.7).

  1. Between two sequence points, an object is modified more than once, or is modified and the prior value is read other than to determine the value to be stored (6.5).

  1. An exceptional condition occurs during the evaluation of an expression (6.5).

  1. An object has its stored value accessed other than by an lvalue of an allowable type (6.5).

  1. An attempt is made to modify the result of a function call, a conditional operator, an assignment operator, or a comma operator, or to access it after the next sequence point (6.5.2.2, 6.5.15, 6.5.16, 6.5.17).

  1. For a call to a function without a function prototype in scope, the number of arguments does not equal the number of parameters (6.5.2.2).

  1. For call to a function without a function prototype in scope where the function is defined with a function prototype, either the prototype ends with an ellipsis or the types of the arguments after promotion are not compatible with the types of the parameters (6.5.2.2).

  1. For a call to a function without a function prototype in scope where the function is not defined with a function prototype, the types of the arguments after promotion are not compatible with those of the parameters after promotion (with certain exceptions) (6.5.2.2).

  1. A function is defined with a type that is not compatible with the type (of the expression) pointed to by the expression that denotes the called function (6.5.2.2).

  1. The operand of the unary * operator has an invalid value (6.5.3.2).

  1. A pointer is converted to other than an integer or pointer type (6.5.4).

  1. The value of the second operand of the / or % operator is zero (6.5.5).

  1. Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that does not point into, or just beyond, the same array object (6.5.6).

  1. Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that points just beyond the array object and is used as the operand of a unary * operator that is evaluated (6.5.6).

  1. Pointers that do not point into, or just beyond, the same array object are subtracted (6.5.6).

  1. An array subscript is out of range, even if an object is apparently accessible with the given subscript (as in the lvalue expression a[1][7] given the declaration int a[4][5]) (6.5.6).

  1. The result of subtracting two pointers is not representable in an object of type ptrdiff_t (6.5.6).

  1. An expression is shifted by a negative number or by an amount greater than or equal to the width of the promoted expression (6.5.7).

  1. An expression having signed promoted type is left-shifted and either the value of the expression is negative or the result of shifting would be not be representable in the promoted type (6.5.7).

  1. Pointers that do not point to the same aggregate or union (nor just beyond the same array object) are compared using relational operators (6.5.8).

  1. An object is assigned to an inexactly overlapping object or to an exactly overlapping object with incompatible type (6.5.16.1).

  1. An expression that is required to be an integer constant expression does not have an integer type; has operands that are not integer constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, or immediately-cast floating constants; or contains casts (outside operands to sizeof operators) other than conversions of arithmetic types to integer types (6.6).

  1. A constant expression in an initializer is not, or does not evaluate to, one of the following: an arithmetic constant expression, a null pointer constant, an address constant, or an address constant for an object type plus or minus an integer constant expression (6.6).

  1. An arithmetic constant expression does not have arithmetic type; has operands that are not integer constants, floating constants, enumeration constants, character constants, or sizeof expressions; or contains casts (outside operands to sizeof operators) other than conversions of arithmetic types to arithmetic types (6.6).

  1. The value of an object is accessed by an array-subscript [], member-access . or ->, address &, or indirection * operator or a pointer cast in creating an address constant (6.6).

  1. An identifier for an object is declared with no linkage and the type of the object is incomplete after its declarator, or after its init-declarator if it has an initializer (6.7).

  1. A function is declared at block scope with an explicit storage-class specifier other than extern (6.7.1).

  1. A structure or union is defined as containing no named members (6.7.2.1).

  1. An attempt is made to access, or generate a pointer to just past, a flexible array member of a structure when the referenced object provides no elements for that array (6.7.2.1).

  1. When the complete type is needed, an incomplete structure or union type is not completed in the same scope by another declaration of the tag that defines the content (6.7.2.3).

  1. An attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type (6.7.3).

  1. An attempt is made to refer to an object defined with a volatile-qualified type through use of an lvalue with non-volatile-qualified type (6.7.3).

  1. The specification of a function type includes any type qualifiers (6.7.3).

  1. Two qualified types that are required to be compatible do not have the identically qualified version of a compatible type (6.7.3).

  1. An object which has been modified is accessed through a restrict-qualified pointer to a const-qualified type, or through a restrict-qualified pointer and another pointer that are not both based on the same object (6.7.3.1).

  1. A restrict-qualified pointer is assigned a value based on another restricted pointer whose associated block neither began execution before the block associated with this pointer, nor ended before the assignment (6.7.3.1).

  1. A function with external linkage is declared with an inline function specifier, but is not also defined in the same translation unit (6.7.4).

  1. Two pointer types that are required to be compatible are not identically qualified, or are not pointers to compatible types (6.7.5.1).

  1. The size expression in an array declaration is not a constant expression and evaluates at program execution time to a nonpositive value (6.7.5.2).

  1. In a context requiring two array types to be compatible, they do not have compatible element types, or their size specifiers evaluate to unequal values (6.7.5.2).

  1. A declaration of an array parameter includes the keyword static within the [ and ] and the corresponding argument does not provide access to the first element of an array with at least the specified number of elements (6.7.5.3).

  1. A storage-class specifier or type qualifier modifies the keyword void as a function parameter type list (6.7.5.3).

  1. In a context requiring two function types to be compatible, they do not have compatible return types, or their parameters disagree in use of the ellipsis terminator or the number and type of parameters (after default argument promotion, when there is no parameter type list or when one type is specified by a function definition with an identifier list) (6.7.5.3).

  1. The value of an unnamed member of a structure or union is used (6.7.8).

  1. The initializer for a scalar is neither a single expression nor a single expression enclosed in braces (6.7.8).

  1. The initializer for a structure or union object that has automatic storage duration is neither an initializer list nor a single expression that has compatible structure or union type (6.7.8).

  1. The initializer for an aggregate or union, other than an array initialized by a string literal, is not a brace-enclosed list of initializers for its elements or members (6.7.8).

  1. An identifier with external linkage is used, but in the program there does not exist exactly one external definition for the identifier, or the identifier is not used and there exist multiple external definitions for the identifier (6.9).

  1. A function definition includes an identifier list, but the types of the parameters are not declared in a following declaration list (6.9.1).

  1. An adjusted parameter type in a function definition is not an object type (6.9.1).

  1. A function that accepts a variable number of arguments is defined without a parameter type list that ends with the ellipsis notation (6.9.1).

  1. The } that terminates a function is reached, and the value of the function call is used by the caller (6.9.1).

  1. An identifier for an object with internal linkage and an incomplete type is declared with a tentative definition (6.9.2).

  1. The token defined is generated during the expansion of a #if or #elif preprocessing directive, or the use of the defined unary operator does not match one of the two specified forms prior to macro replacement (6.10.1).

  1. The #include preprocessing directive that results after expansion does not match one of the two header name forms (6.10.2).

  1. The character sequence in an #include preprocessing directive does not start with a letter (6.10.2).

  1. There are sequences of preprocessing tokens within the list of macro arguments that would otherwise act as preprocessing directives (6.10.3).

  1. The result of the preprocessing operator # is not a valid character string literal (6.10.3.2).

  1. The result of the preprocessing operator ## is not a valid preprocessing token (6.10.3.3).

  1. The #line preprocessing directive that results after expansion does not match one of the two well-defined forms, or its digit sequence specifies zero or a number greater than 2147483647 (6.10.4).

  1. A non-STDC #pragma preprocessing directive that is documented as causing translation failure or some other form of undefined behavior is encountered (6.10.6).

  1. A #pragma STDC preprocessing directive does not match one of the well-defined forms (6.10.6).

  1. The name of a predefined macro, or the identifier defined, is the subject of a #define or #undef preprocessing directive (6.10.8).

  1. An attempt is made to copy an object to an overlapping object by use of a library function, other than as explicitly allowed (e.g., memmove) (clause 7).

  1. A file with the same name as one of the standard headers, not provided as part of the implementation, is placed in any of the standard places that are searched for included source files (7.1.2).

  1. A header is included within an external declaration or definition (7.1.2).

  1. A function, object, type, or macro that is specified as being declared or defined by some standard header is used before any header that declares or defines it is included (7.1.2).

  1. A standard header is included while a macro is defined with the same name as a keyword (7.1.2).

  1. The program attempts to declare a library function itself, rather than via a standard header, but the declaration does not have external linkage (7.1.2).

  1. The program declares or defines a reserved identifier, other than as allowed by 7.1.4 (7.1.3).

  1. The program removes the definition of a macro whose name begins with an underscore and either an uppercase letter or another underscore (7.1.3).

  1. An argument to a library function has an invalid value or a type not expected by a function with variable number of arguments (7.1.4).

  1. The pointer passed to a library function array parameter does not have a value such that all address computations and object accesses are valid (7.1.4).

  1. The macro definition of assert is suppressed to obtain access to an actual function (7.2).

  1. The argument to the assert macro does not have a scalar type (7.2).

  1. The CX_LIMITED_RANGE, FENV_ACCESS, or FP_CONTRACT pragma is used in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement (7.3.4, 7.6.1, 7.12.2).

  1. The value of an argument to a character handling function is neither equal to the value of EOF nor representable as an unsigned char (7.4).

  1. A macro definition of errno is suppressed in order to access an actual object, or the program defines an identifier with the name errno (7.5).

  1. Part of the program tests floating-point status flags, sets floating-point control modes, or runs under non-default mode settings, but was translated with the state for the FENV_ACCESS pragma “off” (7.6.1).

  1. The exception-mask argument for one of the functions that provide access to the floating-point status flags has a nonzero value not obtained by bitwise OR of the floating-point exception macros (7.6.2).

  1. The fesetexceptflag function is used to set floating-point status flags that were not specified in the call to the fegetexceptflag function that provided the value of the corresponding fexcept_t object (7.6.2.4).

  1. The argument to fesetenv or feupdateenv is neither an object set by a call to fegetenv or feholdexcept, nor is it an environment macro (7.6.4.3, 7.6.4.4).

  1. The value of the result of an integer arithmetic or conversion function cannot be represented (7.8.2.1, 7.8.2.2, 7.8.2.3, 7.8.2.4, 7.20.6.1, 7.20.6.2, 7.20.1).

  1. The program modifies the string pointed to by the value returned by the setlocale function (7.11.1.1).

  1. The program modifies the structure pointed to by the value returned by the localeconv function (7.11.2.1).

  1. A macro definition of math_errhandling is suppressed or the program defines an identifier with the name math_errhandling (7.12).

  1. An argument to a floating-point classification or comparison macro is not of real floating type (7.12.3, 7.12.14).

  1. A macro definition of setjmp is suppressed in order to access an actual function, or the program defines an external identifier with the name setjmp (7.13).

  1. An invocation of the setjmp macro occurs other than in an allowed context (7.13.2.1).

  1. The longjmp function is invoked to restore a nonexistent environment (7.13.2.1).

  1. After a longjmp, there is an attempt to access the value of an object of automatic storage class with non-volatile-qualified type, local to the function containing the invocation of the corresponding setjmp macro, that was changed between the setjmp invocation and longjmp call (7.13.2.1).

  1. The program specifies an invalid pointer to a signal handler function (7.14.1.1).

  1. A signal handler returns when the signal corresponded to a computational exception (7.14.1.1).

  1. A signal occurs as the result of calling the abort or raise function, and the signal handler calls the raise function (7.14.1.1).

  1. A signal occurs other than as the result of calling the abort or raise function, and the signal handler refers to an object with static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t, or calls any function in the standard library other than the abort function, the _Exit function, or the signal function (for the same signal number) (7.14.1.1).

  1. The value of errno is referred to after a signal occurred other than as the result of calling the abort or raise function and the corresponding signal handler obtained a SIG_ERR return from a call to the signal function (7.14.1.1).

  1. A signal is generated by an asynchronous signal handler (7.14.1.1).

  1. A function with a variable number of arguments attempts to access its varying arguments other than through a properly declared and initialized va_list object, or before the va_start macro is invoked (7.15, 7.15.1.1, 7.15.1.4).

  1. The macro va_arg is invoked using the parameter ap that was passed to a function that invoked the macro va_arg with the same parameter (7.15).

  1. A macro definition of va_start, va_arg, va_copy, or va_end is suppressed in order to access an actual function, or the program defines an external identifier with the name va_copy or va_end (7.15.1).

  1. The va_start or va_copy macro is invoked without a corresponding invocation of the va_end macro in the same function, or vice versa (7.15.1, 7.15.1.2, 7.15.1.3, 7.15.1.4).

  1. The type parameter to the va_arg macro is not such that a pointer to an object of that type can be obtained simply by postfixing a * (7.15.1.1).

  1. The va_arg macro is invoked when there is no actual next argument, or with a specified type that is not compatible with the promoted type of the actual next argument, with certain exceptions (7.15.1.1).

  1. The va_copy or va_start macro is called to initialize a va_list that was previously initialized by either macro without an intervening invocation of the va_end macro for the same va_list (7.15.1.2, 7.15.1.4).

  1. The parameter parmN of a va_start macro is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions (7.15.1.4).

  1. The member designator parameter of an offsetof macro is an invalid right operand of the . operator for the type parameter, or designates a bit-field (7.17).

  1. The argument in an instance of one of the integer-constant macros is not a decimal, octal, or hexadecimal constant, or it has a value that exceeds the limits for the corresponding type (7.18.4).

  1. A byte input/output function is applied to a wide-oriented stream, or a wide character input/output function is applied to a byte-oriented stream (7.19.2).

  1. Use is made of any portion of a file beyond the most recent wide character written to a wide-oriented stream (7.19.2).

  1. The value of a pointer to a FILE object is used after the associated file is closed (7.19.3).

  1. The stream for the fflush function points to an input stream or to an update stream in which the most recent operation was input (7.19.5.2).

  1. The string pointed to by the mode argument in a call to the fopen function does not exactly match one of the specified character sequences (7.19.5.3).

  1. An output operation on an update stream is followed by an input operation without an intervening call to the fflush function or a file positioning function, or an input operation on an update stream is followed by an output operation with an intervening call to a file positioning function (7.19.5.3).

  1. An attempt is made to use the contents of the array that was supplied in a call to the setvbuf function (7.19.5.6).

  1. There are insufficient arguments for the format in a call to one of the formatted input/output functions, or an argument does not have an appropriate type (7.19.6.1, 7.19.6.2, 7.24.2.1, 7.24.2.2).

  1. The format in a call to one of the formatted input/output functions or to the strftime or wcsftime function is not a valid multibyte character sequence that begins and ends in its initial shift state (7.19.6.1, 7.19.6.2, 7.23.3.5, 7.24.2.1, 7.24.2.2, 7.24.5.1).

  1. In a call to one of the formatted output functions, a precision appears with a conversion specifier other than those described (7.19.6.1, 7.24.2.1).

  1. A conversion specification for a formatted output function uses an asterisk to denote an argument-supplied field width or precision, but the corresponding argument is not provided (7.19.6.1, 7.24.2.1).

  1. A conversion specification for a formatted output function uses a # or 0 flag with a conversion specifier other than those described (7.19.6.1, 7.24.2.1).

  1. A conversion specification for one of the formatted input/output functions uses a length modifier with a conversion specifier other than those described (7.19.6.1, 7.19.6.2, 7.24.2.1, 7.24.2.2).

  1. An s conversion specifier is encountered by one of the formatted output functions, and the argument is missing the null terminator (unless a precision is specified that does not require null termination) (7.19.6.1, 7.24.2.1).

  1. An n conversion specification for one of the formatted input/output functions includes any flags, an assignment-suppressing character, a field width, or a precision (7.19.6.1, 7.19.6.2, 7.24.2.1, 7.24.2.2).

  1. A % conversion specifier is encountered by one of the formatted input/output functions, but the complete conversion specification is not exactly %% (7.19.6.1, 7.19.6.2, 7.24.2.1, 7.24.2.2).

  1. An invalid conversion specification is found in the format for one of the formatted input/output functions, or the strftime or wcsftime function (7.19.6.1, 7.19.6.2, 7.23.3.5, 7.24.2.1, 7.24.2.2, 7.24.5.1).

  1. The number of characters transmitted by a formatted output function is greater than INT_MAX (7.19.6.1, 7.19.6.3, 7.19.6.8, 7.19.6.10).

  1. The result of a conversion by one of the formatted input functions cannot be represented in the corresponding object, or the receiving object does not have an appropriate type (7.19.6.2, 7.24.2.2).

  1. A c, s, or [ conversion specifier is encountered by one of the formatted input functions, and the array pointed to by the corresponding argument is not large enough to accept the input sequence (and a null terminator if the conversion specifier is s or [) (7.19.6.2, 7.24.2.2).

  1. A c, s, or [ conversion specifier with an l qualifier is encountered by one of the formatted input functions, but the input is not a valid multibyte character sequence that begins in the initial shift state (7.19.6.2, 7.24.2.2).

  1. The input item for a %p conversion by one of the formatted input functions is not a value converted earlier during the same program execution (7.19.6.2, 7.24.2.2).

  1. The vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf, vsscanf, vfwprintf, vfwscanf, vswprintf, vswscanf, vwprintf, or vwscanf function is called with an improperly initialized va_list argument, or the argument is used (other than in an invocation of va_end) after the function returns (7.19.6.8, 7.19.6.9, 7.19.6.10, 7.19.6.11, 7.19.6.12, 7.19.6.13, 7.19.6.14, 7.24.2.5, 7.24.2.6, 7.24.2.7, 7.24.2.8, 7.24.2.9, 7.24.2.10).

  1. The contents of the array supplied in a call to the fgets, gets, or fgetws function are used after a read error occurred (7.19.7.2, 7.19.7.7, 7.24.3.2).

  1. The file position indicator for a binary stream is used after a call to the ungetc function where its value was zero before the call (7.19.7.11).

  1. The file position indicator for a stream is used after an error occurred during a call to the fread or fwrite function (7.19.8.1, 7.19.8.2)

  1. A partial element read by a call to the fread function is used (7.19.8.1).

  1. The fseek function is called for a text stream with a nonzero offset and either the offset was not returned by a previous successful call to the ftell function on a stream associated with the same file or whence is not SEEK_SET (7.19.9.2).

  1. The fsetpos function is called to set a position that was not returned by a previous successful call to the fgetpos function on a stream associated with the same file (7.19.9.3).

  1. A non-null pointer returned by a call to the calloc, malloc, or realloc function with a zero requested size is used to access an object (7.20.3).

  1. The value of a pointer that refers to space deallocated by a call to the free or realloc function is used (7.20.3).

  1. The pointer argument to the free or realloc function does not match a pointer earlier returned by calloc, malloc, or realloc, or the space has been deallocated by a call to free or realloc (7.20.3.2, 7.20.3.4).

  1. The value of the object allocated by the malloc function is used (7.20.3.3).

  1. The value of any bytes in a new object allocated by the realloc function beyond the size of the old object are used (7.20.3.4).

  1. The program executes more than one call to the exit function (7.20.4.3).

  1. During the call to a function registered with the atexit function, a call is made to the longjmp function that would terminate the call to the registered function (7.20.4.3).

  1. The string set up by the getenv or strerror function is modified by the program (7.20.4.5, 7.21.6.2).

  1. A command is executed through the system function in a way that is documented as causing termination or some other form of undefined behavior (7.20.4.6).

  1. A searching or sorting utility function is called with an invalid pointer argument, even if the number of elements is zero (7.20.5).

  1. The comparison function called by a searching or sorting utility function alters the contents of the array being searched or sorted, or returns ordering values inconsistently (7.20.5).

  1. The array being searched by the bsearch function does not have its elements in proper order (7.20.5.1).

  1. The current conversion state is used by a multibyte/wide character conversion function after changing the LC_CTYPE category (7.20.7).

  1. A string or wide string utility function is instructed to access an array beyond the end of an object (7.21.1, 7.24.4).

  1. A string or wide string utility function is called with an invalid pointer argument, even if the length is zero (7.21.1, 7.24.4).

  1. The contents of the destination array are used after a call to the strxfrm, strftime, wcsxfrm, or wcsftime function in which the specified length was too small to hold the entire null-terminated result (7.21.4.5, 7.23.3.5, 7.24.4.4.4, 7.24.5.1).

  1. The first argument in the very first call to the strtok or wcstok is a null pointer (7.21.5.8, 7.24.4.5.7).

  1. The type of an argument to a type-generic macro is not compatible with the type of the corresponding parameter of the selected function (7.22).

  1. A complex argument is supplied for a generic parameter of a type-generic macro that has no corresponding complex function (7.22).

  1. The argument corresponding to an s specifier without an l qualifier in a call to the fwprintf function does not point to a valid multibyte character sequence that begins in the initial shift state (7.24.2.11).

  1. In a call to the wcstok function, the object pointed to by ptr does not have the value stored by the previous call for the same wide string (7.24.4.5.7).

  1. An mbstate_t object is used inappropriately (7.24.6).

  1. The value of an argument of type wint_t to a wide character classification or case mapping function is neither equal to the value of WEOF nor representable as a wchar_t (7.25.1).

  1. The iswctype function is called using a different LC_CTYPE category from the one in effect for the call to the wctype function that returned the description (7.25.2.2.1).

  1. The towctrans function is called using a different LC_CTYPE category from the one in effect for the call to the wctrans function that returned the description (7.25.3.2.1).

C11 undefined behaviours

  1. A “shall” or “shall not” requirement that appears outside of a constraint is violated (clause 4).

  1. A nonempty source file does not end in a new-line character which is not immediately preceded by a backslash character or ends in a partial preprocessing token or comment (5.1.1.2).

  1. Token concatenation produces a character sequence matching the syntax of a universal character name (5.1.1.2)

  1. A program in a hosted environment does not define a function named main using one of the specified forms (5.1.2.2.1)

  1. The execution of a program contains a data race (5.1.2.4).

  1. A character not in the basic source character set is encountered in a source file, except in an identifier, a character constant, a string literal, a header name, a comment, or a preprocessing token that is never converted to a token (5.2.1).

  1. An identifier, comment, string literal, character constant, or header name contains an invalid multibyte character or does not begin and end in the initial shift state (5.2.1.2).

  1. The same identifier has both internal and external linkage in the same translation unit (6.2.2).

  1. An object is referred to outside of its lifetime (6.2.4).

  1. The value of a pointer to an object whose lifetime has ended is used (6.2.4).

  1. The value of an object with automatic storage duration is used while it is indeterminate (6.2.4, 6.7.9, 6.8).

  1. A trap representation is read by an lvalue expression that does not have character type (6.2.6.1).

  1. A trap representation is produced by a side effect that modifies any part of the object using an lvalue expression that does not have character type (6.2.6.1).

  1. The arguments to certain operators are such that could produce a negative zero result, but the implementation does not support negative zeros (6.2.6.2).

  1. Two declarations of the same object or function specify types that are not compatible (6.2.7).

  1. A program requires the formation of a composite type from a variable length array type whose size is specified by an expression that is not evaluated (6.2.7).

  1. Conversion to or from an integer type produces a value outside the range that can be represented (6.3.1.4).

  1. Demotion of one real floating type to another produces a value outside the range that can be represented (6.3.1.5).

  1. An lvalue does not designate an object when evaluated (6.3.2.1).

  1. A non-array lvalue with an incomplete type is used in a context that requires the value of the designated object (6.3.2.1).

  1. An lvalue designating an object of automatic storage duration that could have been declared with the register storage class is used in a context that requires the value of the designated object, but the object is uninitialized. (6.3.2.1).

  1. An lvalue having array type is converted to a pointer to the initial element of the array, and the array object has register storage class (6.3.2.1).

  1. An attempt is made to use the value of a void expression, or an implicit or explicit conversion (except to void) is applied to a void expression (6.3.2.2).

  1. Conversion of a pointer to an integer type produces a value outside the range that can be represented (6.3.2.3).

  1. Conversion between two pointer types produces a result that is incorrectly aligned (6.3.2.3).

  1. A pointer is used to call a function whose type is not compatible with the referenced type (6.3.2.3).

  1. An unmatched ‘ or “ character is encountered on a logical source line during tokenization (6.4).

  1. A reserved keyword token is used in translation phase 7 or 8 for some purpose other than as a keyword (6.4.1).

  1. A universal character name in an identifier does not designate a character whose encoding falls into one of the specified ranges (6.4.2.1).

  1. The initial character of an identifier is a universal character name designating a digit (6.4.2.1).

  1. Two identifiers differ only in nonsignificant characters (6.4.2.1).

  1. The identifier _ _func_ _ is explicitly declared (6.4.2.2).

  1. The program attempts to modify a string literal (6.4.5).

  1. The characters ‘, , “, //, or /* occur in the sequence between the < and > delimiters, or the characters ‘, , //, or /* occur in the sequence between the “ delimiters, in a header name preprocessing token (6.4.7).

  1. Between two sequence points, an object is modified more than once, or is modified and the prior value is read other than to determine the value to be stored (6.5).

  1. An exceptional condition occurs during the evaluation of an expression (6.5).

  1. An object has its stored value accessed other than by an lvalue of an allowable type (6.5).

  1. For a call to a function without a function prototype in scope, the number of arguments does not equal the number of parameters (6.5.2.2).

  1. For call to a function without a function prototype in scope where the function is defined with a function prototype, either the prototype ends with an ellipsis or the types of the arguments after promotion are not compatible with the types of the parameters (6.5.2.2).

  1. For a call to a function without a function prototype in scope where the function is not defined with a function prototype, the types of the arguments after promotion are not compatible with those of the parameters after promotion (with certain exceptions) (6.5.2.2).

  1. A function is defined with a type that is not compatible with the type (of the expression) pointed to by the expression that denotes the called function (6.5.2.2).

  1. A member of an atomic structure or union is accessed (6.5.2.3)

  1. The operand of the unary * operator has an invalid value (6.5.3.2).

  1. A pointer is converted to other than an integer or pointer type (6.5.4).

  1. The value of the second operand of the / or % operator is zero (6.5.5).

  1. Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that does not point into, or just beyond, the same array object (6.5.6).

  1. Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that points just beyond the array object and is used as the operand of a unary * operator that is evaluated (6.5.6).

  1. Pointers that do not point into, or just beyond, the same array object are subtracted (6.5.6).

  1. An array subscript is out of range, even if an object is apparently accessible with the given subscript (as in the lvalue expression a[1][7] given the declaration int a[4][5]) (6.5.6).

  1. The result of subtracting two pointers is not representable in an object of type ptrdiff_t (6.5.6).

  1. An expression is shifted by a negative number or by an amount greater than or equal to the width of the promoted expression (6.5.7).

  1. An expression having signed promoted type is left-shifted and either the value of the expression is negative or the result of shifting would be not be representable in the promoted type (6.5.7).

  1. Pointers that do not point to the same aggregate or union (nor just beyond the same array object) are compared using relational operators (6.5.8).

  1. An object is assigned to an inexactly overlapping object or to an exactly overlapping object with incompatible type (6.5.16.1).

  1. An expression that is required to be an integer constant expression does not have an integer type; has operands that are not integer constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, _Alignof expressions, or immediately-cast floating constants; or contains casts (outside operands to sizeof and _Alignof operators) other than conversions of arithmetic types to integer types (6.6).

  1. A constant expression in an initializer is not, or does not evaluate to, one of the following: an arithmetic constant expression, a null pointer constant, an address constant, or an address constant for an object type plus or minus an integer constant expression (6.6).

  1. An arithmetic constant expression does not have arithmetic type; has operands that are not integer constants, floating constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, or _Alignof expressions; or contains casts (outside operands to sizeof or _Alignof operators) other than conversions of arithmetic types to arithmetic types (6.6).

  1. The value of an object is accessed by an array-subscript [], member-access . or ->, address &, or indirection * operator or a pointer cast in creating an address constant (6.6).

  1. An identifier for an object is declared with no linkage and the type of the object is incomplete after its declarator, or after its init-declarator if it has an initializer (6.7).

  1. A function is declared at block scope with an explicit storage-class specifier other than extern (6.7.1).

  1. A structure or union is defined without any named members (including those specified indirectly via anonymous structures and unions) (6.7.2.1).

  1. An attempt is made to access, or generate a pointer to just past, a flexible array member of a structure when the referenced object provides no elements for that array (6.7.2.1).

  1. When the complete type is needed, an incomplete structure or union type is not completed in the same scope by another declaration of the tag that defines the content (6.7.2.3).

  1. An attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type (6.7.3).

  1. An attempt is made to refer to an object defined with a volatile-qualified type through use of an lvalue with non-volatile-qualified type (6.7.3).

  1. The specification of a function type includes any type qualifiers (6.7.3).

  1. Two qualified types that are required to be compatible do not have the identically qualified version of a compatible type (6.7.3).

  1. An object which has been modified is accessed through a restrict-qualified pointer to a const-qualified type, or through a restrict-qualified pointer and another pointer that are not both based on the same object (6.7.3.1).

  1. A restrict-qualified pointer is assigned a value based on another restricted pointer whose associated block neither began execution before the block associated with this pointer, nor ended before the assignment (6.7.3.1).

  1. A function with external linkage is declared with an inline function specifier, but is not also defined in the same translation unit (6.7.4).

  1. A function declared with a _Noreturn function specifier returns to its caller (6.7.4).

  1. The definition of an object has an alignment specifier and another declaration of that object has a different alignment specifier (6.7.5).

  1. Declarations of an object in different translation units have different alignment specifiers (6.7.5).

  1. Two pointer types that are required to be compatible are not identically qualified, or are not pointers to compatible types (6.7.6.1).

  1. The size expression in an array declaration is not a constant expression and evaluates at program execution time to a nonpositive value (6.7.6.2).

  1. In a context requiring two array types to be compatible, they do not have compatible element types, or their size specifiers evaluate to unequal values (6.7.6.2).

  1. A declaration of an array parameter includes the keyword static within the [ and ] and the corresponding argument does not provide access to the first element of an array with at least the specified number of elements (6.7.6.3).

  1. A storage-class specifier or type qualifier modifies the keyword void as a function parameter type list (6.7.6.3).

  1. In a context requiring two function types to be compatible, they do not have compatible return types, or their parameters disagree in use of the ellipsis terminator or the number and type of parameters (after default argument promotion, when there is no parameter type list or when one type is specified by a function definition with an identifier list) (6.7.6.3).

  1. The value of an unnamed member of a structure or union is used (6.7.9).

  1. The initializer for a scalar is neither a single expression nor a single expression enclosed in braces (6.7.9).

  1. The initializer for a structure or union object that has automatic storage duration is neither an initializer list nor a single expression that has compatible structure or union type (6.7.9).

  1. The initializer for an aggregate or union, other than an array initialized by a string literal, is not a brace-enclosed list of initializers for its elements or members (6.7.9).

  1. An identifier with external linkage is used, but in the program there does not exist exactly one external definition for the identifier, or the identifier is not used and there exist multiple external definitions for the identifier (6.9).

  1. A function definition includes an identifier list, but the types of the parameters are not declared in a following declaration list (6.9.1).

  1. An adjusted parameter type in a function definition is not a complete object type (6.9.1).

  1. A function that accepts a variable number of arguments is defined without a parameter type list that ends with the ellipsis notation (6.9.1).

  1. The } that terminates a function is reached, and the value of the function call is used by the caller (6.9.1).

  1. An identifier for an object with internal linkage and an incomplete type is declared with a tentative definition (6.9.2).

  1. The token defined is generated during the expansion of a #if or #elif preprocessing directive, or the use of the defined unary operator does not match one of the two specified forms prior to macro replacement (6.10.1).

  1. The #include preprocessing directive that results after expansion does not match one of the two header name forms (6.10.2).

  1. The character sequence in an #include preprocessing directive does not start with a letter (6.10.2).

  1. There are sequences of preprocessing tokens within the list of macro arguments that would otherwise act as preprocessing directives (6.10.3).

  1. The result of the preprocessing operator # is not a valid character string literal (6.10.3.2).

  1. The result of the preprocessing operator ## is not a valid preprocessing token (6.10.3.3).

  1. The #line preprocessing directive that results after expansion does not match one of the two well-defined forms, or its digit sequence specifies zero or a number greater than 2147483647 (6.10.4).

  1. A non-STDC #pragma preprocessing directive that is documented as causing translation failure or some other form of undefined behavior is encountered (6.10.6).

  1. A #pragma STDC preprocessing directive does not match one of the well-defined forms (6.10.6).

  1. The name of a predefined macro, or the identifier defined, is the subject of a #define or #undef preprocessing directive (6.10.8).

  1. An attempt is made to copy an object to an overlapping object by use of a library function, other than as explicitly allowed (e.g., memmove) (clause 7).

  1. A file with the same name as one of the standard headers, not provided as part of the implementation, is placed in any of the standard places that are searched for included source files (7.1.2).

  1. A header is included within an external declaration or definition (7.1.2).

  1. A function, object, type, or macro that is specified as being declared or defined by some standard header is used before any header that declares or defines it is included (7.1.2).

  1. A standard header is included while a macro is defined with the same name as a keyword (7.1.2).

  1. The program attempts to declare a library function itself, rather than via a standard header, but the declaration does not have external linkage (7.1.2).

  1. The program declares or defines a reserved identifier, other than as allowed by 7.1.4 (7.1.3).

  1. The program removes the definition of a macro whose name begins with an underscore and either an uppercase letter or another underscore (7.1.3).

  1. An argument to a library function has an invalid value or a type not expected by a function with variable number of arguments (7.1.4).

  1. The pointer passed to a library function array parameter does not have a value such that all address computations and object accesses are valid (7.1.4).

  1. The macro definition of assert is suppressed to obtain access to an actual function (7.2).

  1. The argument to the assert macro does not have a scalar type (7.2).

  1. The CX_LIMITED_RANGE, FENV_ACCESS, or FP_CONTRACT pragma is used in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement (7.3.4, 7.6.1, 7.12.2).

  1. The value of an argument to a character handling function is neither equal to the value of EOF nor representable as an unsigned char (7.4).

  1. A macro definition of errno is suppressed in order to access an actual object, or the program defines an identifier with the name errno (7.5).

  1. Part of the program tests floating-point status flags, sets floating-point control modes, or runs under non-default mode settings, but was translated with the state for the FENV_ACCESS pragma “off” (7.6.1).

  1. The exception-mask argument for one of the functions that provide access to the floating-point status flags has a nonzero value not obtained by bitwise OR of the floating-point exception macros (7.6.2).

  1. The fesetexceptflag function is used to set floating-point status flags that were not specified in the call to the fegetexceptflag function that provided the value of the corresponding fexcept_t object (7.6.2.4).

  1. The argument to fesetenv or feupdateenv is neither an object set by a call to fegetenv or feholdexcept, nor is it an environment macro (7.6.4.3, 7.6.4.4).

  1. The value of the result of an integer arithmetic or conversion function cannot be represented (7.8.2.1, 7.8.2.2, 7.8.2.3, 7.8.2.4, 7.20.6.1, 7.20.6.2, 7.20.1).

  1. The program modifies the string pointed to by the value returned by the setlocale function (7.11.1.1).

  1. The program modifies the structure pointed to by the value returned by the localeconv function (7.11.2.1).

  1. A macro definition of math_errhandling is suppressed or the program defines an identifier with the name math_errhandling (7.12).

  1. An argument to a floating-point classification or comparison macro is not of real floating type (7.12.3, 7.12.14).

  1. A macro definition of setjmp is suppressed in order to access an actual function, or the program defines an external identifier with the name setjmp (7.13).

  1. An invocation of the setjmp macro occurs other than in an allowed context (7.13.2.1).

  1. The longjmp function is invoked to restore a nonexistent environment (7.13.2.1).

  1. After a longjmp, there is an attempt to access the value of an object of automatic storage class with non-volatile-qualified type, local to the function containing the invocation of the corresponding setjmp macro, that was changed between the setjmp invocation and longjmp call (7.13.2.1).

  1. The program specifies an invalid pointer to a signal handler function (7.14.1.1).

  1. A signal handler returns when the signal corresponded to a computational exception (7.14.1.1).

  1. A signal handler called in response to SIGFPE, SIGILL, SIGSEGV, or any other implementation-defined value corresponding to a computational exception returns (7.14.1.1).

  1. A signal occurs as the result of calling the abort or raise function, and the signal handler calls the raise function (7.14.1.1).

  1. A signal occurs other than as the result of calling the abort or raise function, and the signal handler refers to an object with static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t, or calls any function in the standard library other than the abort function, the _Exit function, or the signal function (for the same signal number) (7.14.1.1).

  1. The value of errno is referred to after a signal occurred other than as the result of calling the abort or raise function and the corresponding signal handler obtained a SIG_ERR return from a call to the signal function (7.14.1.1).

  1. A signal is generated by an asynchronous signal handler (7.14.1.1).

  1. The signal function is used in a multi-threaded program (7.14.1.1).

  1. A function with a variable number of arguments attempts to access its varying arguments other than through a properly declared and initialized va_list object, or before the va_start macro is invoked (7.16, 7.16.1.1, 7.16.1.4).

  1. The macro va_arg is invoked using the parameter ap that was passed to a function that invoked the macro va_arg with the same parameter (7.16).

  1. A macro definition of va_start, va_arg, va_copy, or va_end is suppressed in order to access an actual function, or the program defines an external identifier with the name va_copy or va_end (7.16.1).

  1. The va_start or va_copy macro is invoked without a corresponding invocation of the va_end macro in the same function, or vice versa (7.16.1, 7.16.1.2, 7.16.1.3, 7.16.1.4).

  1. The type parameter to the va_arg macro is not such that a pointer to an object of that type can be obtained simply by postfixing a * (7.16.1.1).

  1. The va_arg macro is invoked when there is no actual next argument, or with a specified type that is not compatible with the promoted type of the actual next argument, with certain exceptions (7.16.1.1).

  1. The va_copy or va_start macro is called to initialize a va_list that was previously initialized by either macro without an intervening invocation of the va_end macro for the same va_list (7.16.1.2, 7.16.1.4).

  1. The parameter parmN of a va_start macro is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions (7.16.1.4).

  1. The member designator parameter of an offsetof macro is an invalid right operand of the . operator for the type parameter, or designates a bit-field (7.19).

  1. The argument in an instance of one of the integer-constant macros is not a decimal, octal, or hexadecimal constant, or it has a value that exceeds the limits for the corresponding type (7.20.4).

  1. A byte input/output function is applied to a wide-oriented stream, or a wide character input/output function is applied to a byte-oriented stream (7.21.2).

  1. Use is made of any portion of a file beyond the most recent wide character written to a wide-oriented stream (7.21.2).

  1. The value of a pointer to a FILE object is used after the associated file is closed (7.21.3).

  1. The stream for the fflush function points to an input stream or to an update stream in which the most recent operation was input (7.21.5.2).

  1. The string pointed to by the mode argument in a call to the fopen function does not exactly match one of the specified character sequences (7.21.5.3).

  1. An output operation on an update stream is followed by an input operation without an intervening call to the fflush function or a file positioning function, or an input operation on an update stream is followed by an output operation with an intervening call to a file positioning function (7.21.5.3).

  1. An attempt is made to use the contents of the array that was supplied in a call to the setvbuf function (7.21.5.6).

  1. There are insufficient arguments for the format in a call to one of the formatted input/output functions, or an argument does not have an appropriate type (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. The format in a call to one of the formatted input/output functions or to the strftime or wcsftime function is not a valid multibyte character sequence that begins and ends in its initial shift state (7.21.6.1, 7.21.6.2, 7.27.3.5, 7.29.2.1, 7.29.2.2, 7.29.5.1).

  1. In a call to one of the formatted output functions, a precision appears with a conversion specifier other than those described (7.21.6.1, 7.29.2.1).

  1. A conversion specification for a formatted output function uses an asterisk to denote an argument-supplied field width or precision, but the corresponding argument is not provided (7.21.6.1, 7.29.2.1).

  1. A conversion specification for a formatted output function uses a # or 0 flag with a conversion specifier other than those described (7.21.6.1, 7.29.2.1).

  1. A conversion specification for one of the formatted input/output functions uses a length modifier with a conversion specifier other than those described (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. An s conversion specifier is encountered by one of the formatted output functions, and the argument is missing the null terminator (unless a precision is specified that does not require null termination) (7.21.6.1, 7.29.2.1).

  1. An n conversion specification for one of the formatted input/output functions includes any flags, an assignment-suppressing character, a field width, or a precision (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. A % conversion specifier is encountered by one of the formatted input/output functions, but the complete conversion specification is not exactly %% (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. An invalid conversion specification is found in the format for one of the formatted input/output functions, or the strftime or wcsftime function (7.21.6.1, 7.21.6.2, 7.27.3.5, 7.29.2.1, 7.29.2.2, 7.29.5.1).

  1. The number of characters or wide characters transmitted by a formatted output function (or written to an array, or that would have been written to an array) is greater than INT_MAX (7.21.6.1, 7.29.2.1).

  1. The number of input items assigned by a formatted input function is greater than INT_MAX (7.21.6.2, 7.29.2.2).

  1. The result of a conversion by one of the formatted input functions cannot be represented in the corresponding object, or the receiving object does not have an appropriate type (7.21.6.2, 7.29.2.2).

  1. A c, s, or [ conversion specifier is encountered by one of the formatted input functions, and the array pointed to by the corresponding argument is not large enough to accept the input sequence (and a null terminator if the conversion specifier is s or [) (7.21.6.2, 7.29.2.2).

  1. A c, s, or [ conversion specifier with an l qualifier is encountered by one of the formatted input functions, but the input is not a valid multibyte character sequence that begins in the initial shift state (7.21.6.2, 7.29.2.2).

  1. The input item for a %p conversion by one of the formatted input functions is not a value converted earlier during the same program execution (7.21.6.2, 7.29.2.2).

  1. The vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf, vsscanf, vfwprintf, vfwscanf, vswprintf, vswscanf, vwprintf, or vwscanf function is called with an improperly initialized va_list argument, or the argument is used (other than in an invocation of va_end) after the function returns (7.21.6.8, 7.21.6.9, 7.21.6.10, 7.21.6.11, 7.21.6.12, 7.21.6.13, 7.21.6.14, 7.29.2.5, 7.29.2.6, 7.29.2.7, 7.29.2.8, 7.29.2.9, 7.29.2.10).

  1. The contents of the array supplied in a call to the fgets or fgetws function are used after a read error occurred (7.21.7.2, 7.29.3.2).

  1. The file position indicator for a binary stream is used after a call to the ungetc function where its value was zero before the call (7.21.7.10).

  1. The file position indicator for a stream is used after an error occurred during a call to the fread or fwrite function (7.21.8.1, 7.21.8.2).

  1. A partial element read by a call to the fread function is used (7.21.8.1).

  1. The fseek function is called for a text stream with a nonzero offset and either the offset was not returned by a previous successful call to the ftell function on a stream associated with the same file or whence is not SEEK_SET (7.21.9.2).

  1. The fsetpos function is called to set a position that was not returned by a previous successful call to the fgetpos function on a stream associated with the same file (7.21.9.3).

  1. A non-null pointer returned by a call to the calloc, malloc, or realloc function with a zero requested size is used to access an object (7.22.3).

  1. The value of a pointer that refers to space deallocated by a call to the free or realloc function is used (7.22.3).

  1. The alignment requested of the aligned_alloc function is not valid or not supported by the implementation, or the size requested is not an integral multiple of the alignment (7.22.3.1).

  1. The pointer argument to the free or realloc function does not match a pointer earlier returned by a memory management function, or the space has been deallocated by a call to free or realloc (7.22.3.3, 7.22.3.5).

  1. The value of the object allocated by the malloc function is used (7.22.3.4).

  1. The value of any bytes in a new object allocated by the realloc function beyond the size of the old object are used (7.22.3.5).

  1. The program calls the exit or quick_exit function more than once, or calls both functions (7.22.4.4, 7.22.4.7).

  1. During the call to a function registered with the atexit or at_quick_exit function, a call is made to the longjmp function that would terminate the call to the registered function (7.22.4.4, 7.22.4.7).

  1. The string set up by the getenv or strerror function is modified by the program (7.22.4.6, 7.24.6.2).

  1. A signal is raised while the quick_exit function is executing (7.22.4.7).

  1. A command is executed through the system function in a way that is documented as causing termination or some other form of undefined behavior (7.22.4.8).

  1. A searching or sorting utility function is called with an invalid pointer argument, even if the number of elements is zero (7.22.5).

  1. The comparison function called by a searching or sorting utility function alters the contents of the array being searched or sorted, or returns ordering values inconsistently (7.22.5).

  1. The array being searched by the bsearch function does not have its elements in proper order (7.22.5.1).

  1. The current conversion state is used by a multibyte/wide character conversion function after changing the LC_CTYPE category (7.22.7).

  1. A string or wide string utility function is instructed to access an array beyond the end of an object (7.24.1, 7.29.4).

  1. A string or wide string utility function is called with an invalid pointer argument, even if the length is zero (7.24.1, 7.29.4).

  1. The contents of the destination array are used after a call to the strxfrm, strftime, wcsxfrm, or wcsftime function in which the specified length was too small to hold the entire null-terminated result (7.24.4.5, 7.27.3.5, 7.29.4.4.4, 7.29.5.1).

  1. The first argument in the very first call to the strtok or wcstok is a null pointer (7.24.5.8, 7.29.4.5.7).

  1. The type of an argument to a type-generic macro is not compatible with the type of the corresponding parameter of the selected function (7.25).

  1. A complex argument is supplied for a generic parameter of a type-generic macro that has no corresponding complex function (7.25)

  1. At least one member of the broken-down time passed to asctime contains a value outside its normal range, or the calculated year exceeds four digits or is less than the year 1000 (7.27.3.1).

  1. The argument corresponding to an s specifier without an l qualifier in a call to the fwprintf function does not point to a valid multibyte character sequence that begins in the initial shift state (7.29.2.11).

  1. In a call to the wcstok function, the object pointed to by ptr does not have the value stored by the previous call for the same wide string (7.29.4.5.7).

  1. An mbstate_t object is used inappropriately (7.29.6).

  1. The value of an argument of type wint_t to a wide character classification or case mapping function is neither equal to the value of WEOF nor representable as a wchar_t (7.30.1).

  1. The iswctype function is called using a different LC_CTYPE category from the one in effect for the call to the wctype function that returned the description (7.30.2.2.1).

  1. The towctrans function is called using a different LC_CTYPE category from the one in effect for the call to the wctrans function that returned the description (7.30.3.2.1).

C18 undefined behaviours

  1. A “shall” or “shall not” requirement that appears outside of a constraint is violated (clause 4).

  1. A nonempty source file does not end in a new-line character which is not immediately preceded by a backslash character or ends in a partial preprocessing token or comment (5.1.1.2).

  1. Token concatenation produces a character sequence matching the syntax of a universal character name (5.1.1.2)

  1. A program in a hosted environment does not define a function named main using one of the specified forms (5.1.2.2.1)

  1. The execution of a program contains a data race (5.1.2.4).

  1. A character not in the basic source character set is encountered in a source file, except in an identifier, a character constant, a string literal, a header name, a comment, or a preprocessing token that is never converted to a token (5.2.1).

  1. An identifier, comment, string literal, character constant, or header name contains an invalid multibyte character or does not begin and end in the initial shift state (5.2.1.2).

  1. The same identifier has both internal and external linkage in the same translation unit (6.2.2).

  1. An object is referred to outside of its lifetime (6.2.4).

  1. The value of a pointer to an object whose lifetime has ended is used (6.2.4).

  1. The value of an object with automatic storage duration is used while it is indeterminate (6.2.4, 6.7.9, 6.8).

  1. A trap representation is read by an lvalue expression that does not have character type (6.2.6.1).

  1. A trap representation is produced by a side effect that modifies any part of the object using an lvalue expression that does not have character type (6.2.6.1).

  1. The arguments to certain operators are such that could produce a negative zero result, but the implementation does not support negative zeros (6.2.6.2).

  1. Two declarations of the same object or function specify types that are not compatible (6.2.7).

  1. A program requires the formation of a composite type from a variable length array type whose size is specified by an expression that is not evaluated (6.2.7).

  1. Conversion to or from an integer type produces a value outside the range that can be represented (6.3.1.4).

  1. Demotion of one real floating type to another produces a value outside the range that can be represented (6.3.1.5).

  1. An lvalue does not designate an object when evaluated (6.3.2.1).

  1. A non-array lvalue with an incomplete type is used in a context that requires the value of the designated object (6.3.2.1).

  1. An lvalue designating an object of automatic storage duration that could have been declared with the register storage class is used in a context that requires the value of the designated object, but the object is uninitialized. (6.3.2.1).

  1. An lvalue having array type is converted to a pointer to the initial element of the array, and the array object has register storage class (6.3.2.1).

  1. An attempt is made to use the value of a void expression, or an implicit or explicit conversion (except to void) is applied to a void expression (6.3.2.2).

  1. Conversion of a pointer to an integer type produces a value outside the range that can be represented (6.3.2.3).

  1. Conversion between two pointer types produces a result that is incorrectly aligned (6.3.2.3).

  1. A pointer is used to call a function whose type is not compatible with the referenced type (6.3.2.3).

  1. An unmatched ‘ or “ character is encountered on a logical source line during tokenization (6.4).

  1. A reserved keyword token is used in translation phase 7 or 8 for some purpose other than as a keyword (6.4.1).

  1. A universal character name in an identifier does not designate a character whose encoding falls into one of the specified ranges (6.4.2.1).

  1. The initial character of an identifier is a universal character name designating a digit (6.4.2.1).

  1. Two identifiers differ only in nonsignificant characters (6.4.2.1).

  1. The identifier _ _func_ _ is explicitly declared (6.4.2.2).

  1. The program attempts to modify a string literal (6.4.5).

  1. The characters ‘, , “, //, or /* occur in the sequence between the < and > delimiters, or the characters ‘, , //, or /* occur in the sequence between the “ delimiters, in a header name preprocessing token (6.4.7).

  1. Between two sequence points, an object is modified more than once, or is modified and the prior value is read other than to determine the value to be stored (6.5).

  1. An exceptional condition occurs during the evaluation of an expression (6.5).

  1. An object has its stored value accessed other than by an lvalue of an allowable type (6.5).

  1. For a call to a function without a function prototype in scope, the number of arguments does not equal the number of parameters (6.5.2.2).

  1. For call to a function without a function prototype in scope where the function is defined with a function prototype, either the prototype ends with an ellipsis or the types of the arguments after promotion are not compatible with the types of the parameters (6.5.2.2).

  1. For a call to a function without a function prototype in scope where the function is not defined with a function prototype, the types of the arguments after promotion are not compatible with those of the parameters after promotion (with certain exceptions) (6.5.2.2).

  1. A function is defined with a type that is not compatible with the type (of the expression) pointed to by the expression that denotes the called function (6.5.2.2).

  1. A member of an atomic structure or union is accessed (6.5.2.3)

  1. The operand of the unary * operator has an invalid value (6.5.3.2).

  1. A pointer is converted to other than an integer or pointer type (6.5.4).

  1. The value of the second operand of the / or % operator is zero (6.5.5).

  1. If the quotient a/b is not representable, the behavior of both a/b and a%b (6.5.5).

  1. Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that does not point into, or just beyond, the same array object (6.5.6).

  1. Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that points just beyond the array object and is used as the operand of a unary * operator that is evaluated (6.5.6).

  1. Pointers that do not point into, or just beyond, the same array object are subtracted (6.5.6).

  1. An array subscript is out of range, even if an object is apparently accessible with the given subscript (as in the lvalue expression a[1][7] given the declaration int a[4][5]) (6.5.6).

  1. The result of subtracting two pointers is not representable in an object of type ptrdiff_t (6.5.6).

  1. An expression is shifted by a negative number or by an amount greater than or equal to the width of the promoted expression (6.5.7).

  1. An expression having signed promoted type is left-shifted and either the value of the expression is negative or the result of shifting would be not be representable in the promoted type (6.5.7).

  1. Pointers that do not point to the same aggregate or union (nor just beyond the same array object) are compared using relational operators (6.5.8).

  1. An object is assigned to an inexactly overlapping object or to an exactly overlapping object with incompatible type (6.5.16.1).

  1. An expression that is required to be an integer constant expression does not have an integer type; has operands that are not integer constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, _Alignof expressions, or immediately-cast floating constants; or contains casts (outside operands to sizeof and _Alignof operators) other than conversions of arithmetic types to integer types (6.6).

  1. A constant expression in an initializer is not, or does not evaluate to, one of the following: an arithmetic constant expression, a null pointer constant, an address constant, or an address constant for an object type plus or minus an integer constant expression (6.6).

  1. An arithmetic constant expression does not have arithmetic type; has operands that are not integer constants, floating constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, or _Alignof expressions; or contains casts (outside operands to sizeof or _Alignof operators) other than conversions of arithmetic types to arithmetic types (6.6).

  1. The value of an object is accessed by an array-subscript [], member-access . or ->, address &, or indirection * operator or a pointer cast in creating an address constant (6.6).

  1. An identifier for an object is declared with no linkage and the type of the object is incomplete after its declarator, or after its init-declarator if it has an initializer (6.7).

  1. A function is declared at block scope with an explicit storage-class specifier other than extern (6.7.1).

  1. A structure or union is defined without any named members (including those specified indirectly via anonymous structures and unions) (6.7.2.1).

  1. An attempt is made to access, or generate a pointer to just past, a flexible array member of a structure when the referenced object provides no elements for that array (6.7.2.1).

  1. When the complete type is needed, an incomplete structure or union type is not completed in the same scope by another declaration of the tag that defines the content (6.7.2.3).

  1. An attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type (6.7.3).

  1. An attempt is made to refer to an object defined with a volatile-qualified type through use of an lvalue with non-volatile-qualified type (6.7.3).

  1. The specification of a function type includes any type qualifiers (6.7.3).

  1. Two qualified types that are required to be compatible do not have the identically qualified version of a compatible type (6.7.3).

  1. An object which has been modified is accessed through a restrict-qualified pointer to a const-qualified type, or through a restrict-qualified pointer and another pointer that are not both based on the same object (6.7.3.1).

  1. A restrict-qualified pointer is assigned a value based on another restricted pointer whose associated block neither began execution before the block associated with this pointer, nor ended before the assignment (6.7.3.1).

  1. A function with external linkage is declared with an inline function specifier, but is not also defined in the same translation unit (6.7.4).

  1. A function declared with a _Noreturn function specifier returns to its caller (6.7.4).

  1. The definition of an object has an alignment specifier and another declaration of that object has a different alignment specifier (6.7.5).

  1. Declarations of an object in different translation units have different alignment specifiers (6.7.5).

  1. Two pointer types that are required to be compatible are not identically qualified, or are not pointers to compatible types (6.7.6.1).

  1. The size expression in an array declaration is not a constant expression and evaluates at program execution time to a nonpositive value (6.7.6.2).

  1. In a context requiring two array types to be compatible, they do not have compatible element types, or their size specifiers evaluate to unequal values (6.7.6.2).

  1. A declaration of an array parameter includes the keyword static within the [ and ] and the corresponding argument does not provide access to the first element of an array with at least the specified number of elements (6.7.6.3).

  1. A storage-class specifier or type qualifier modifies the keyword void as a function parameter type list (6.7.6.3).

  1. In a context requiring two function types to be compatible, they do not have compatible return types, or their parameters disagree in use of the ellipsis terminator or the number and type of parameters (after default argument promotion, when there is no parameter type list or when one type is specified by a function definition with an identifier list) (6.7.6.3).

  1. The value of an unnamed member of a structure or union is used (6.7.9).

  1. The initializer for a scalar is neither a single expression nor a single expression enclosed in braces (6.7.9).

  1. The initializer for a structure or union object that has automatic storage duration is neither an initializer list nor a single expression that has compatible structure or union type (6.7.9).

  1. The initializer for an aggregate or union, other than an array initialized by a string literal, is not a brace-enclosed list of initializers for its elements or members (6.7.9).

  1. An identifier with external linkage is used, but in the program there does not exist exactly one external definition for the identifier, or the identifier is not used and there exist multiple external definitions for the identifier (6.9).

  1. A function definition includes an identifier list, but the types of the parameters are not declared in a following declaration list (6.9.1).

  1. An adjusted parameter type in a function definition is not a complete object type (6.9.1).

  1. A function that accepts a variable number of arguments is defined without a parameter type list that ends with the ellipsis notation (6.9.1).

  1. The } that terminates a function is reached, and the value of the function call is used by the caller (6.9.1).

  1. An identifier for an object with internal linkage and an incomplete type is declared with a tentative definition (6.9.2).

  1. A non-directive preprocessing directive is executed (6.10).

  1. The token defined is generated during the expansion of a #if or #elif preprocessing directive, or the use of the defined unary operator does not match one of the two specified forms prior to macro replacement (6.10.1).

  1. The #include preprocessing directive that results after expansion does not match one of the two header name forms (6.10.2).

  1. The character sequence in an #include preprocessing directive does not start with a letter (6.10.2).

  1. There are sequences of preprocessing tokens within the list of macro arguments that would otherwise act as preprocessing directives (6.10.3).

  1. The result of the preprocessing operator # is not a valid character string literal (6.10.3.2).

  1. The result of the preprocessing operator ## is not a valid preprocessing token (6.10.3.3).

  1. The #line preprocessing directive that results after expansion does not match one of the two well-defined forms, or its digit sequence specifies zero or a number greater than 2147483647 (6.10.4).

  1. A non-STDC #pragma preprocessing directive that is documented as causing translation failure or some other form of undefined behavior is encountered (6.10.6).

  1. A #pragma STDC preprocessing directive does not match one of the well-defined forms (6.10.6).

  1. The name of a predefined macro, or the identifier defined, is the subject of a #define or #undef preprocessing directive (6.10.8).

  1. An attempt is made to copy an object to an overlapping object by use of a library function, other than as explicitly allowed (e.g., memmove) (clause 7).

  1. A file with the same name as one of the standard headers, not provided as part of the implementation, is placed in any of the standard places that are searched for included source files (7.1.2).

  1. A header is included within an external declaration or definition (7.1.2).

  1. A function, object, type, or macro that is specified as being declared or defined by some standard header is used before any header that declares or defines it is included (7.1.2).

  1. A standard header is included while a macro is defined with the same name as a keyword (7.1.2).

  1. The program attempts to declare a library function itself, rather than via a standard header, but the declaration does not have external linkage (7.1.2).

  1. The program declares or defines a reserved identifier, other than as allowed by 7.1.4 (7.1.3).

  1. The program removes the definition of a macro whose name begins with an underscore and either an uppercase letter or another underscore (7.1.3).

  1. An argument to a library function has an invalid value or a type not expected by a function with variable number of arguments (7.1.4).

  1. The pointer passed to a library function array parameter does not have a value such that all address computations and object accesses are valid (7.1.4).

  1. The macro definition of assert is suppressed to obtain access to an actual function (7.2).

  1. The argument to the assert macro does not have a scalar type (7.2).

  1. The CX_LIMITED_RANGE, FENV_ACCESS, or FP_CONTRACT pragma is used in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement (7.3.4, 7.6.1, 7.12.2).

  1. The value of an argument to a character handling function is neither equal to the value of EOF nor representable as an unsigned char (7.4).

  1. A macro definition of errno is suppressed in order to access an actual object, or the program defines an identifier with the name errno (7.5).

  1. Part of the program tests floating-point status flags, sets floating-point control modes, or runs under non-default mode settings, but was translated with the state for the FENV_ACCESS pragma “off” (7.6.1).

  1. The exception-mask argument for one of the functions that provide access to the floating-point status flags has a nonzero value not obtained by bitwise OR of the floating-point exception macros (7.6.2).

  1. The fesetexceptflag function is used to set floating-point status flags that were not specified in the call to the fegetexceptflag function that provided the value of the corresponding fexcept_t object (7.6.2.4).

  1. The argument to fesetenv or feupdateenv is neither an object set by a call to fegetenv or feholdexcept, nor is it an environment macro (7.6.4.3, 7.6.4.4).

  1. The value of the result of an integer arithmetic or conversion function cannot be represented (7.8.2.1, 7.8.2.2, 7.8.2.3, 7.8.2.4, 7.20.6.1, 7.20.6.2, 7.20.1).

  1. The program modifies the string pointed to by the value returned by the setlocale function (7.11.1.1).

  1. The program modifies the structure pointed to by the value returned by the localeconv function (7.11.2.1).

  1. A macro definition of math_errhandling is suppressed or the program defines an identifier with the name math_errhandling (7.12).

  1. An argument to a floating-point classification or comparison macro is not of real floating type (7.12.3, 7.12.14).

  1. A macro definition of setjmp is suppressed in order to access an actual function, or the program defines an external identifier with the name setjmp (7.13).

  1. An invocation of the setjmp macro occurs other than in an allowed context (7.13.2.1).

  1. The longjmp function is invoked to restore a nonexistent environment (7.13.2.1).

  1. After a longjmp, there is an attempt to access the value of an object of automatic storage class with non-volatile-qualified type, local to the function containing the invocation of the corresponding setjmp macro, that was changed between the setjmp invocation and longjmp call (7.13.2.1).

  1. The program specifies an invalid pointer to a signal handler function (7.14.1.1).

  1. A signal handler returns when the signal corresponded to a computational exception (7.14.1.1).

  1. A signal handler called in response to SIGFPE, SIGILL, SIGSEGV, or any other implementation-defined value corresponding to a computational exception returns (7.14.1.1).

  1. A signal occurs as the result of calling the abort or raise function, and the signal handler calls the raise function (7.14.1.1).

  1. A signal occurs other than as the result of calling the abort or raise function, and the signal handler refers to an object with static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t, or calls any function in the standard library other than the abort function, the _Exit function, or the signal function (for the same signal number) (7.14.1.1).

  1. The value of errno is referred to after a signal occurred other than as the result of calling the abort or raise function and the corresponding signal handler obtained a SIG_ERR return from a call to the signal function (7.14.1.1).

  1. A signal is generated by an asynchronous signal handler (7.14.1.1).

  1. The signal function is used in a multi-threaded program (7.14.1.1).

  1. A function with a variable number of arguments attempts to access its varying arguments other than through a properly declared and initialized va_list object, or before the va_start macro is invoked (7.16, 7.16.1.1, 7.16.1.4).

  1. The macro va_arg is invoked using the parameter ap that was passed to a function that invoked the macro va_arg with the same parameter (7.16).

  1. A macro definition of va_start, va_arg, va_copy, or va_end is suppressed in order to access an actual function, or the program defines an external identifier with the name va_copy or va_end (7.16.1).

  1. The va_start or va_copy macro is invoked without a corresponding invocation of the va_end macro in the same function, or vice versa (7.16.1, 7.16.1.2, 7.16.1.3, 7.16.1.4).

  1. The type parameter to the va_arg macro is not such that a pointer to an object of that type can be obtained simply by postfixing a * (7.16.1.1).

  1. The va_arg macro is invoked when there is no actual next argument, or with a specified type that is not compatible with the promoted type of the actual next argument, with certain exceptions (7.16.1.1).

  1. The va_copy or va_start macro is called to initialize a va_list that was previously initialized by either macro without an intervening invocation of the va_end macro for the same va_list (7.16.1.2, 7.16.1.4).

  1. The parameter parmN of a va_start macro is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions (7.16.1.4).

  1. The macro definition of a generic function is suppressed in order to access an actual function (7.17.1).

  1. The member designator parameter of an offsetof macro is an invalid right operand of the . operator for the type parameter, or designates a bit-field (7.19).

  1. The argument in an instance of one of the integer-constant macros is not a decimal, octal, or hexadecimal constant, or it has a value that exceeds the limits for the corresponding type (7.20.4).

  1. A byte input/output function is applied to a wide-oriented stream, or a wide character input/output function is applied to a byte-oriented stream (7.21.2).

  1. Use is made of any portion of a file beyond the most recent wide character written to a wide-oriented stream (7.21.2).

  1. The value of a pointer to a FILE object is used after the associated file is closed (7.21.3).

  1. The stream for the fflush function points to an input stream or to an update stream in which the most recent operation was input (7.21.5.2).

  1. The string pointed to by the mode argument in a call to the fopen function does not exactly match one of the specified character sequences (7.21.5.3).

  1. An output operation on an update stream is followed by an input operation without an intervening call to the fflush function or a file positioning function, or an input operation on an update stream is followed by an output operation with an intervening call to a file positioning function (7.21.5.3).

  1. An attempt is made to use the contents of the array that was supplied in a call to the setvbuf function (7.21.5.6).

  1. There are insufficient arguments for the format in a call to one of the formatted input/output functions, or an argument does not have an appropriate type (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. The format in a call to one of the formatted input/output functions or to the strftime or wcsftime function is not a valid multibyte character sequence that begins and ends in its initial shift state (7.21.6.1, 7.21.6.2, 7.27.3.5, 7.29.2.1, 7.29.2.2, 7.29.5.1).

  1. In a call to one of the formatted output functions, a precision appears with a conversion specifier other than those described (7.21.6.1, 7.29.2.1).

  1. A conversion specification for a formatted output function uses an asterisk to denote an argument-supplied field width or precision, but the corresponding argument is not provided (7.21.6.1, 7.29.2.1).

  1. A conversion specification for a formatted output function uses a # or 0 flag with a conversion specifier other than those described (7.21.6.1, 7.29.2.1).

  1. A conversion specification for one of the formatted input/output functions uses a length modifier with a conversion specifier other than those described (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. An s conversion specifier is encountered by one of the formatted output functions, and the argument is missing the null terminator (unless a precision is specified that does not require null termination) (7.21.6.1, 7.29.2.1).

  1. An n conversion specification for one of the formatted input/output functions includes any flags, an assignment-suppressing character, a field width, or a precision (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. A % conversion specifier is encountered by one of the formatted input/output functions, but the complete conversion specification is not exactly %% (7.21.6.1, 7.21.6.2, 7.29.2.1, 7.29.2.2).

  1. An invalid conversion specification is found in the format for one of the formatted input/output functions, or the strftime or wcsftime function (7.21.6.1, 7.21.6.2, 7.27.3.5, 7.29.2.1, 7.29.2.2, 7.29.5.1).

  1. The number of characters or wide characters transmitted by a formatted output function (or written to an array, or that would have been written to an array) is greater than INT_MAX (7.21.6.1, 7.29.2.1).

  1. The number of input items assigned by a formatted input function is greater than INT_MAX (7.21.6.2, 7.29.2.2).

  1. The result of a conversion by one of the formatted input functions cannot be represented in the corresponding object, or the receiving object does not have an appropriate type (7.21.6.2, 7.29.2.2).

  1. A c, s, or [ conversion specifier is encountered by one of the formatted input functions, and the array pointed to by the corresponding argument is not large enough to accept the input sequence (and a null terminator if the conversion specifier is s or [) (7.21.6.2, 7.29.2.2).

  1. A c, s, or [ conversion specifier with an l qualifier is encountered by one of the formatted input functions, but the input is not a valid multibyte character sequence that begins in the initial shift state (7.21.6.2, 7.29.2.2).

  1. The input item for a %p conversion by one of the formatted input functions is not a value converted earlier during the same program execution (7.21.6.2, 7.29.2.2).

  1. The vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf, vsscanf, vfwprintf, vfwscanf, vswprintf, vswscanf, vwprintf, or vwscanf function is called with an improperly initialized va_list argument, or the argument is used (other than in an invocation of va_end) after the function returns (7.21.6.8, 7.21.6.9, 7.21.6.10, 7.21.6.11, 7.21.6.12, 7.21.6.13, 7.21.6.14, 7.29.2.5, 7.29.2.6, 7.29.2.7, 7.29.2.8, 7.29.2.9, 7.29.2.10).

  1. The contents of the array supplied in a call to the fgets or fgetws function are used after a read error occurred (7.21.7.2, 7.29.3.2).

  1. The file position indicator for a binary stream is used after a call to the ungetc function where its value was zero before the call (7.21.7.10).

  1. The file position indicator for a stream is used after an error occurred during a call to the fread or fwrite function (7.21.8.1, 7.21.8.2).

  1. A partial element read by a call to the fread function is used (7.21.8.1).

  1. The fseek function is called for a text stream with a nonzero offset and either the offset was not returned by a previous successful call to the ftell function on a stream associated with the same file or whence is not SEEK_SET (7.21.9.2).

  1. The fsetpos function is called to set a position that was not returned by a previous successful call to the fgetpos function on a stream associated with the same file (7.21.9.3).

  1. A non-null pointer returned by a call to the calloc, malloc, or realloc function with a zero requested size is used to access an object (7.22.3).

  1. The value of a pointer that refers to space deallocated by a call to the free or realloc function is used (7.22.3).

  1. The pointer argument to the free or realloc function does not match a pointer earlier returned by a memory management function, or the space has been deallocated by a call to free or realloc (7.22.3.3, 7.22.3.5).

  1. The value of the object allocated by the malloc function is used (7.22.3.4).

  1. The value of any bytes in a new object allocated by the realloc function beyond the size of the old object are used (7.22.3.5).

  1. The program calls the exit or quick_exit function more than once, or calls both functions (7.22.4.4, 7.22.4.7).

  1. During the call to a function registered with the atexit or at_quick_exit function, a call is made to the longjmp function that would terminate the call to the registered function (7.22.4.4, 7.22.4.7).

  1. The string set up by the getenv or strerror function is modified by the program (7.22.4.6, 7.24.6.2).

  1. A signal is raised while the quick_exit function is executing (7.22.4.7).

  1. A command is executed through the system function in a way that is documented as causing termination or some other form of undefined behavior (7.22.4.8).

  1. A searching or sorting utility function is called with an invalid pointer argument, even if the number of elements is zero (7.22.5).

  1. The comparison function called by a searching or sorting utility function alters the contents of the array being searched or sorted, or returns ordering values inconsistently (7.22.5).

  1. The array being searched by the bsearch function does not have its elements in proper order (7.22.5.1).

  1. The current conversion state is used by a multibyte/wide character conversion function after changing the LC_CTYPE category (7.22.7).

  1. A string or wide string utility function is instructed to access an array beyond the end of an object (7.24.1, 7.29.4).

  1. A string or wide string utility function is called with an invalid pointer argument, even if the length is zero (7.24.1, 7.29.4).

  1. The contents of the destination array are used after a call to the strxfrm, strftime, wcsxfrm, or wcsftime function in which the specified length was too small to hold the entire null-terminated result (7.24.4.5, 7.27.3.5, 7.29.4.4.4, 7.29.5.1).

  1. The first argument in the very first call to the strtok or wcstok is a null pointer (7.24.5.8, 7.29.4.5.7).

  1. The type of an argument to a type-generic macro is not compatible with the type of the corresponding parameter of the selected function (7.25).

  1. A complex argument is supplied for a generic parameter of a type-generic macro that has no corresponding complex function (7.25)

  1. A non-recursive mutex passed to mtx_lock is locked by the calling thread (7.26.4.3).

  1. The mutex passed to mtx_timedlock does not support timeout (7.26.4.4).

  1. The mutex passed to mtx_unlock is not locked by the calling thread (7.26.4.6).

  1. The thread passed to thrd_detach or thrd_join was previously detached or joined with another thread (7.26.5.3, 7.26.5.6).

  1. The tss_create function is called from within a destructor (7.26.6.1).

  1. The key passed to tss_delete, tss_get, or tss_set was not returned by a call to tss_create before the thread commenced executing destructors (7.26.6.2, 7.26.6.3, 7.26.6.4).

  1. At least one member of the broken-down time passed to asctime contains a value outside its normal range, or the calculated year exceeds four digits or is less than the year 1000 (7.27.3.1).

  1. The argument corresponding to an s specifier without an l qualifier in a call to the fwprintf function does not point to a valid multibyte character sequence that begins in the initial shift state (7.29.2.11).

  1. In a call to the wcstok function, the object pointed to by ptr does not have the value stored by the previous call for the same wide string (7.29.4.5.7).

  1. An mbstate_t object is used inappropriately (7.29.6).

  1. The value of an argument of type wint_t to a wide character classification or case mapping function is neither equal to the value of WEOF nor representable as a wchar_t (7.30.1).

  1. The iswctype function is called using a different LC_CTYPE category from the one in effect for the call to the wctype function that returned the description (7.30.2.2.1).

  1. The towctrans function is called using a different LC_CTYPE category from the one in effect for the call to the wctrans function that returned the description (7.30.3.2.1).

Service Classification and Prioritization

This chapter illustrates how ECLAIR services can be classified according to different criteria and how classifications can be used for purposes such as subsetting and prioritization.

The next section introduces the main technique for service classification, which is based on service tagging and report tagging. The following sections introduce ready-made classifications that ECLAIR users may find useful.

Classifying Services via Tagging

As explained in Generic Service Options, every ECLAIR service can be associated with multiple tags. Such tags are ideal to classify services according to different criteria. Consider the following example:

-config=MC3.D1.1,tag=MRB_DOCU_MC3
-config=MC3.D3.1,tag=MRB_DOCU_MC3
-config=MC3.D4.2,tag=MRB_DOCU_MC3

The three services MC3.D1.1, MC3.D3.1 and MC3.D4.2 are associated with the tag MRB_DOCU_MC3, in addition to all tags such services may already be associated with. The new tag can be used for different purposes. For example, to enable all services with that tag at once:

-enable=MRB_DOCU_MC3

For another example, here is how you could tag all reports from these service with report tag MRB:DOCU:

-config=MRB_DOCU_MC3,reports+={"MRB:DOCU","any()"}

Once reports are tagged, you can process them in many different ways, e.g., to temporarily hide them selectively.

Rationale-Based Classification of MISRA C Guidelines

The paper A Rationale-Based Classification of MISRA C Guidelines [5] defines new classification that associates guidelines with their main rationale. This can be used for subsetting the guidelines in projects that do not have MISRA-compliance requirements. For projects that do have MISRA-compliance requirements the classification allows for prioritizing the work. ECL command files to tag the service and the corresponding reports using this classification are provided in

PREFIX/eclair-VERSION/share/config/recipes/MRB_*

There is one ECL file for each of the 16 named sets of guidelines described in [5]. For instance, enabling and tagging for the LTLM subset (Language/Toolchain/Library Misuse) of the latest version of MISRA C:2012 can be achieved by including

PREFIX/eclair-VERSION/share/config/recipes/MRB_LTLM_MC.ecl

in the ECLAIR project configuration files.

Software Quality Objectives’ Classification

The paper Software Quality Objectives for Source Code [10] defines six Software Quality Objectives (SQO), which are associated with four quality levels, from 1 (lowest quality) to 4 (highest quality). The Software Quality Objectives, which are numbered from 1 to 6, can be associated with ECLAIR services. An example of such association is given by the ECL command files provided in

PREFIX/eclair-VERSION/share/config/recipes/SQO_*

For each ECLAIR package and each SQO there is an ECL file enabling and tagging the services and reports available with the package and corresponding to the SQO. For example, the ECL file

PREFIX/eclair-VERSION/share/config/recipes/SQO_4_MP1.ecl

enables the services available in the MP1 package that have been associated with SQO 4. Note that [10] does not define a precise classification. The classification encoded in the ECL files supplied with ECLAIR in

PREFIX/eclair-VERSION/share/config/recipes/SQO_*

dependens also on subjective considerations: use those as examples and starting points for adaptation.

Classification of MISRA C guidelines with respect to CWE

ECLAIR offers a recipe to map rules and directives belonging to the MISRA C:2012 Revision 1 coding standard [51] to related weaknesses listed in the Common Weaknesses Enumeration (CWE). This is accomplished trough rule tagging, as explained in Classifying Services via Tagging. ECL command files to tag the service and the reports produced using this classification are provided in

PREFIX/eclair-VERSION/share/config/recipes/CWE_MC.ecl

The following statements shall be taken into account when performing an analysis using this classification:

  • A MISRA C guideline can be mapped to zero or more CWE identifiers.

  • If a CWE identifier is not mapped to any MISRA C guideline, no reports will be tagged with this CWE.

Using the command file is straightforward: in the ECLAIR project configuration files, if you want to check CWE-192 and CWE-194:

-eval_file=""install_dir"/share/config/recipes/CWE_MC.ecl"

-enable=CWE-112_MC
-enable=CWE-194_MC

This will produce reports for any MISRA C:2012 rule associated with such CWEs (MC3.D1.1, MC3.D4.2, MC3.R10.1, MC3.R10.3, MC3.R10.4, MC3.R10.7), whose tag is CWE:CWE-{ID}.

Classification of MISRA C guidelines with respect to CERT-C:2016

ECLAIR offers a recipe to map rules and directives belonging to the MISRA C:2012 Revision 1 coding standard [51] to related rules listed in the SEI CERT C:2016 coding standard [32] (see SEI CERT C Coding Standard). This is accomplished trough rule tagging, as explained in Classifying Services via Tagging. ECL command files to tag the service and the reports produced using this classification are provided in

PREFIX/eclair-VERSION/share/config/recipes/CERT-C_MC.ecl

The following statements shall be taken into account when performing an analysis using this classification:

  • A MISRA C guideline can be mapped to zero or more CERT-C rules.

  • If a CERT-C rule identifier is not mapped to any MISRA C guideline, no reports will be tagged with this CERT-C rule.

Using the command file is straightforward: in the ECLAIR project configuration files, if you want to check rule INT34-C:

-eval_file=""install_dir"/share/config/recipes/CERT-C_MC.ecl"

-enable=CERT-INT34-C_MC

This will produce reports for any MISRA C:2012 rule associated with such rule (MC3.R10.1, MC3.R12.2), whose tag is CERT:INT34-C.

Adoption of Deviation Permits in ECLAIR

Deviation Permits

This chapter illustrates how ECLAIR can support developers in the quick adoption of a subset of allowed deviations from coding standards’s rules, understood to strike a balance between code readability, efficiency and the compliance with such standards.

MISRA C:2012 deviation permits

ECLAIR offers recipes for the adoption of deviation permits published in MISRA C:2012 Permits [53] that allows certain common deviations from MISRA C:2012 [45] directives and rules, with an emphasis on allowing automatically generated code and code not intended to be reviewed by humans to be non-compliant with respect to a subset of rules and directives. To accomplish this, several configuration files, one for each permit, have been designed to be suitable for drop-in inclusion in projects that are already making use of the ECLAIR software verification platform. When used, these recipes will tag all violations of the rules and directives with appropriate labels, with the aim of allowing developers to easily distinguish them from other reports, and optionally hide them.

Each permit refers to a rule, has a unique identifier and a series of requirements that need to be fulfilled in order to be applicable to the code at hand; one or more permit may exist for each rule or directive. The configuration files that implement each permit are available in the directory

PREFIX/eclair-VERSION/share/config/recipes/MPER_MC.*

The naming scheme for each file is MPER_MC.R{RULE}_{ID}.{VER}.ecl which translates to the naming scheme found in [53] as follows: R-{RULE}.{ID}.{VER}.

To apply a deviation permit, you just need to include the following snippet in an .ecl configuration file or command line:

-eval_file={PREFIX}/eclair-{VERSION}/share/config/recipes/MPER_MC.R10.1_A.1.ecl

If additional configuration is needed to apply the permit, it is described inside each file. As an example, to apply the permit mentioned above, you should specify before evaluating the permit file which files contain automatically generated code by tagging them as autogen like so:

-file_tag+={autogen, "^foo/bar/baz/.*$"}

Some permits may require additional documentation that is outside of the scope of static analysis and automatic checking; in these cases, the deviations will be partially justified, with a description of what developers need to do ensure compliance with the permit’s requirements.

There are some cases where developers are expected to insert documentation in the form of suitably formatted code comments to justify the adoption of a permit. The configuration recipes provide a default format, stated in the corresponding file, but allow changing both the format and the location of such comments. To do so, see the documentation for -area_selector and -loc_selector to learn more. By default, a suitably formatted comment should be placed at the row above any location of the violation.

Example comment for permit R16.4_A.1:

-file_tag+={autogen, "^foo\\.c$"}

-eval_file=""install_dir"/share/config/recipes/MPER_MC.R16.4_A.1.ecl"

-enable=MC3.R16.4
enum Color { GREEN, ORANGE, RED };

void test(enum Color c) {
/* no default label is needed in the following switch statement because:
 * 1) all the enumeration constants are handled;
 * 2) the variable c is guaranteed not to be assigned any other value.
 */
switch (c) {
    case GREEN:
    go();
    break;
    case ORANGE:
    wait();
    break;
    case RED:
    stop();
    break;
}
}

Tagging/Hiding Reports

This chapter illustrates several ways ECLAIR offers to tag reports. Using the tagging system you can (temporarily) hide reports, or filter them in different convenient ways. We will also recommend a taxonomy, which you could use to classified your reports. Note that we deliberately talk about report hiding, which is not necessarily report suppression. If a report is suppressed, the information it conveys is lost forever; if it is hidden, the information is available for further processing. Moreover, what has been hidden and why it was hidden is very valuable information.

The next section introduces the subject of hiding and provides crucial advice about handling the hiding vs complying dilemma. The subsequent sections explain all the report tagging and report-hiding features of ECLAIR.

To Hide or Not To Hide

Report hiding, especially when there is a large number of reports, is something all users of static analysis tools have to take care of, one way or another. A large number of reports usually indicates that the adopted coding convention was not effectively enforced on the project. It is well known that the highest payoff from the adoption of coding conventions is achieved when the conventions are adopted at the very beginning of a project and systematically enforced with the help of a high-quality tool. Unfortunately this cannot always be done.

It is important to distinguish between temporary hiding, which is an obvious measure to focus on selected reports without being distracted by non-pertinent reports, and permanent hiding, which is something to be considered carefully.

The temporary hiding mechanism on reports is carried out thanks the use of the more flexible system of the tagging. The tagging is an ECLAIR feature which allows the user to manually tag a report, hiding means labelling with the special tag hide. We discourage the user from indiscriminate use of the hide tag, the ECLAIR team encourages the use of a well-defined and useful taxonomy for tagging. This will make it possible to hide the reports on a tag basis without risks and, at the same time, enrich the reports database with user-provided information.

All coding standards have provision for so called deviations. A deviation is the choice not to comply with a certain coding rule for a certain portion of the code. Such a choice must of course be motivated: we will call the argument that motivates a deviation its justification. Deviation procedures are essential, e.g., to cope with:

  • language implementation header files (e.g., string.h for C) that do not comply with the chosen coding conventions;

  • legacy or foreign code that does not comply and cannot be modified;

  • code portions that cannot be compliant with respect to a certain convention (e.g., they have to use unions);

  • code portions that could, in principle, be changed to be compliant but pragmatic considerations suggest otherwise (e.g., very critical pieces of code that have undergone extensive verification and validation);

  • code for which the tool does not have enough information to exclude a potential problem.

Note though that, with a high-quality tool such as ECLAIR, all reports should be considered with care first; then risks should be weighed; only then can a decision about deviation be taken in a sensible way. For instance, code that cannot be changed will, in the end, have almost all its reports hidden, but it would be a mistake to hide the reports from the outset: some reports concerning that code may contain information that you would be better off knowing rather than ignoring.

In addition, what has to be properly understood is that deviation has a cost, just like compliance. Such cost must be accounted for carefully as, in many situations, complying is cheaper than deviating. As an example, let us consider the much-hated and much-misunderstood rule 2.2 of MISRA-C:2004 (see page 30 of [62] ):

Source code shall only use /* ... */ style comments.

Many people too quickly dismiss the rule: they simply want to use BCPL/C99-style // comments. In the spirit of MISRA-C:2004, such a choice can be justified provided that:

  1. the team understands // comments perfectly;

  2. the compilers used in the project do the right thing with them.

Concerning the first point, consider the following:

/\
/ Is this a comment?

//\
/**\
\
\
Is this a comment? \
\
\
*/

/*//*/ char and_this // = '?'
/**/;

For a less contrived example, note how a function call can be inadvertently commented out:

// see critical.* in c:\project\src\
critical_function();

As far as the second point is concerned (our compilers do the right thing), the question is: did they test the compilers? Note that:

  • a project meant to comply with MISRA-C:2004 will most likely be compiled with a C90 compiler;

  • probably any extension to C90 by that compiler has not received adequate testing;

  • different C90 compilers treat // comments differently.

So, in the end we should ask ourselves: what is easier/cheaper? Sticking to /* */ comments or performing extensive in-house testing of the compiler to make sure // comments are handled properly?

With all this well in mind, we can proceed to the next sections where the tagging and deviation mechanisms supported by ECLAIR are illustrated both from the pragmatic point of view (pros and cons of doing it) and, of course, from the technical point of view (how to do it).

Only Enable the Rules that are Important for You

Suppose your project is based on MISRA-C:2004 [62] but it was decided that continue can be used in the project (presumably because the team understands its use perfectly) and functions with a variable number of arguments could be used as well (presumably because the team understands them perfectly and because the compiler was thoroughly tested on variadic functions). This calls for a global deviation from rules MC2.14.5 (see page 69 of [62] ) and MC2.16.1 (see page 74 of [62] ), respectively. If in your configuration you enabled all MC2 checkers in one shot, then you will have to disable the services checking these two rules, so that you will have something like:

# Enable all MC2.* checkers.
-enable=MC2
...
-disable=MC2.14.5
-disable=MC2.16.1
...

If, instead, you prefer to enable checkers on an individual basis, simply omit to enable those you do not want to enable:

...
-enable=MC2.14.4
#-enable=MC2.14.5
...
-enable=MC2.15.5
#-enable=MC2.16.1
...

See Global Options for more information on -config.

Note that this form of hiding is indeed a suppression: ECLAIR will not even run the checkers that are not enabled. The downside is that you will get no data on whether and how often continue and variadic functions are used in the project; on the other hand, the analysis will be quicker since less work has to be done.

Give Sufficient Information to ECLAIR

Sometimes an unwanted report is due to the fact that ECLAIR does not have sufficient information to avoid it. For example, consider rule 16.8 of MISRA-C:2004 (see page 75 of [62] ):

All exit paths from a function with non-void return type shall have an explicit return statement with an expression.

Consider also the following code, in which the main() function does not end with a return statement:

int main(void) {
   ...
   /* This will never return. */
   kernel_enter();
}

ECLAIR will issue a report concerning non-compliance of rule MC2.16.8. If this is unwanted, then one can comply with the rule by adding a return statement before the closing brace. Or, if the comment really has to be trusted and kernel_enter() will never ever return, then there are two options:

  1. if the compiler supports attribute noreturn and the declaration of kernel_enter() is under control of the user, the declaration should be improved with the attribute, which will be honored by ECLAIR;

  2. otherwise, ECLAIR can be informed of this fact in the configuration:

    -call_properties+={"decl(name(kernel_enter))",{noreturn}}
    

See -call_properties for more information on how to specify the properties of calls.

The Report Tagging System

Every report produced by ECLAIR can be tagged, there are several ways to tag a report or a group of reports, these will be discussed in the following sections Encapsulate, Tag and Justify and Mark Locally and Justify.

Using the option tags=show in the configuration of service B.REPORT.ECB you can specify to display alongside the reports also the report tag used and their origins:

eclair_env -enable=B.REPORT.ECB -config=B.REPORT.ECB,tags=show -enable=RULE -- ...

A report tag can have one of two forms:

Domain:Tag_Name

where Domain is a tag domain and Tag_Name is a report tag in Domain,

Tag_Name

where Tag_Name is a report tag in the domain tag.

Within a domain, the tag _NO_TAG is reserved for a report with no specified tag for that domain and hide for hiding a report.

Report tags (including hide) can be remapped to other tags using the global configuration option remap_rtag defined in Global Options.

Note that the tagging feature is available only for the reports, it’s not possible use it with the options -source_files and -frames, for this last two cases you are forced the use the hiding.

Suggested Report Tags

As already mentioned, the ECLAIR team encourages the use of a well-defined tagging system for reports. We provide the following suggested tagging model, if it doesn’t meet your company/team’s expectations and needs feel free to adapt it as you wish.

adopted

The report should be considered originated by adopted code without any contribution of native code to the report.

safe

The report is correct but the specific behavior is safe under every aspect assumed to be covered by the guideline.

relied

The report is correct but the rule concerns exclusively “developer confusion” or readability matters that are not relevant for adopted code, which is assumed to work as is and it is not meant to be read, reviewed or modified by human programmers. To be used for adopted code only.

false-positive

In the opinion of the developer the violation report is not correct and the problem has been notified to the tool provider. To be used only for violation reports.

compliant

The developer can prove that the possible non-compliance shown by caution report cannot happen in any situation and can motivate such claim. To be used only for caution reports.

false-negative

The developer has found a non-compliance not shown by tool and the problem has been notified to the tool provider. To be used only with a temporary comment-based suppression of the form /* -E> false-negative SERVICE 1 FIXME ... DESCRIPTION ... */

During the work toward establishing compliance, the tags mentioned above can be used to add a further tag hide. This possibility is to be used only temporarily in order to reduce cluttering and facilitate day-by-day work. In the final analysis and consequent report generation only the reports for (partially) disapplied guidelines ought to be tagged with hide.

Encapsulate, Tag and Justify

Wholesale deviation from coding rules should be limited to rules that do not belong to the coding convention you wish to adopt. For other rules, one of the best techniques for deviation is to encapsulate the violating code into macros or functions and then deviate just those macros and functions. For example, according to rule 18.4 of MISRA-C:2004 (see page 80 of [62] .)

Unions shall not be used.

Yet, many projects do need to use unions, albeit only for very specific and limited purposes. The right thing to do is to encapsulate all the code that requires unions into macros and/or functions, mark those as exempt from rule 18.2 along with a proper justification. The next two sections exemplify this approach.

Macro Encapsulation

Consider rule 14.9 of MISRA-C:2004 (see page 70 of [62] ):

An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement.

The following piece of code violates the rule:

#define DEBOUNCE(e) \
  do { int i; for (i=0; i<500; i++) { if (!(e)) i = 0; } } while (0)

Compliance would be trivial to achieve. If this is not wanted or not possible, we could take advantage of the fact the non-compliance is encapsulated into a macro. We can thus limit the scope of the deviation to the expansion of the DEBOUNCE macro, like this, where justification should be replaced with our motives for that choice:

-doc="justification"
-config=MC2.14.9,reports+={safe,"all_area(all_loc(macro(^DEBOUNCE$)))"}

In this example, we have chosen to mark the report with the tag safe, since the code is not compliant, but the user considers the code safe under every aspect. This makes easy in a second moment to retrieve a list with all the violations of this type. This would not possible using only the hide tag.

See reports for details about tagging/hiding reports.

Function/Method Encapsulation

The scope of deviations can be limited to designated function and method definitions. For instance, consider the following code:

uint8_t
compute_checksum(const uint8_t *data_ptr, uint16_t count) {
  register uint8_t checksum = 0;
  while (count--) {
    checksum += *data_ptr++;
  }
  return (-checksum);
}

The compute_checksum() function violates rule 12.9 of MISRA-C:2004 (see page 62 of [62] ):

The unary minus operator shall not be applied to an expression whose underlying type is unsigned.

If the deviation is intentional and can be justified, a deviation limited to the compute_checksum() function can be expressed as follows:

-doc="justification"
-config=MC2.12.9,reports+={safe,"all_area(context(^compute_checksum\\(.*$))"}

See reports for more information about tagging/hiding reports based on declaration contexts.

Exempt Some Files

In a project, there may be files or entire subtrees in the source tree that are not meant to comply with the rules adopted for the rest of the project. These files and directories can be easily exempted. For example, exempting any location in the examples subtree of the project tree can be done as follows:

-doc="Not meant to comply with any rule."
-reports+={adopted,"all_area(all_loc(^examples/.*$))"}

We have chosen the tag adopted since an typical reason the hide groups of files is that they are adopted code.

See the -reports global option to learn how to specify the reports to be hidden.

To do this on a rule-by-rule basis use the reports option of -config. For example, suppose you have a bunch of automatically-generated C source files in your project, which can be recognized by an mg_ prefix in their name; suppose further that such files are allowed to use goto statements, thus deviating from MISRA-C:2004 rule 14.4 (see page 69 of [62] ). Such a deviation can be simply implemented by

-doc="Autogenerated"
-config=MC2.14.4,reports+={adopted,"all_area(all_loc(^(.*/)?mg_[^/]*\\.c))"}

With the -reports global option and with the reports option of -config ECLAIR does all the analysis work and then tags the reports according to the configuration. From the methodological point of view, this is, by far, the best thing to do and the only one suitable to safety- and mission-critical development. However, it is also possible to instruct ECLAIR to ignore parts of the project. This has drawbacks: if ECLAIR does not see all the code it will tell you, e.g., that a certain function is never called whereas in fact it is called by code ECLAIR did not see. Worse, it may fail to report that a set of functions is mutually recursive, because is was not allowed to see one of the links in the cyclic call chain. Nevertheless, in the day-to-day use of ECLAIR, it may make sense to use one of the following options in order to speed-up the analysis, provided they are not used in the final run, the run that is supposed to obtain the final compliance matrix.

In order to instruct ECLAIR not to visit top-level declarations in the (often huge) Boost C++ libraries header files you can use something like

-doc="Boost header files."
-source_files+={hide,"^C:/Program Files/boost/.*$"}

See the -source_files global option for information on the specification of the files for which top level declarations should not be visited and tokens should not be checked. Since we are no longer talking about reports (they are not produced), it is not possible to use the ECLAIR tagging system with the option -source_files. In this case, you can only use hide.

Another possibility is to instruct ECLAIR to completely ignore some main files and all those (recursively) included by them. For example, if you want to ignore all files named mg_*.c because they are automatically generated and come with adequate guarantees, you can use the following global configuration:

-doc="Autogenerated."
-frames+={hide,"main(^(.*/)?mg_[^/]*\\.c$)"}

Note that here “ignore” is used in a very strong sense: ECLAIR will not even read those files. In contrast, with -source_files the matching files will be preprocessed and parsed, even though the top-level declarations therein will not be visited.

See the -frames global option for details on the specification of the analysis frames that ECLAIR should ignore. This can also be specified on a rule-by-rule basis using the frames option of -config. Since we are no longer talking about reports (they are not produced), it is not possible to use the ECLAIR tagging system with the option -frames. In this case, you can only use hide.

Note

Use the -source_files and -frames global options and the frames option of -config only if you know what you are doing. In any case:

  • do not use them on the final analysis, the one meant to obtain the final compliance matrix for your software;

  • make sure that the parts ECLAIR ignores or does not visit do not refer to the parts ECLAIR analyzes; for example, if module A refers to module B it may be acceptable to analyze A and ignore/not visit B, but not the other way around.

Mark Locally and Justify

The scope of a deviation can be made even more precise by means of special comments in the source code. These can mark selected code lines and provide a justification as to why the reports for the marked lines should be hidden.

Let us consider again the compute_checksum() function which, as we know, violates rule 12.9 of MISRA-C:2004 (unary minus on unsigned). It also violates rule 12.13 of MISRA-C:2004 (see page 18 of [63] ):

The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.

Such violation reports can be hidden, with justification, by adding special comments to the code, as follows:

uint8_t
compute_checksum_c(const uint8_t *data_ptr, uint16_t count) {
  register uint8_t checksum = 0;
  while (count--) {
    checksum += *data_ptr++; // -E> safe MC2.12.13 0 a justification
  }
  /* -E> safe MC2.12.9 1 another justification */
  return (-checksum);
}

The first comment, // -E> safe MC2.12.13 0 a justification, adds the tag safe to the violation report given by service MC2.12.13 on that line.

The second comment, /* -E> safe MC2.12.9 1 another justification */, adds the tag safe to the violation report given by service MC2.12.9 on that line and 1 following line (hence, just on the following line, since the line with the comment only contains the comment and blank space).

Note that, whenever a violation report includes the tag hide, the report will be hidden.

Alternatively, the documentation can be written once for a set of marked lines using a location label. For example

/* -E> safe MC2.12.9 :CHECKSUM a long documentation */
uint8_t
compute_checksum_c(const uint8_t *data_ptr, uint16_t count) {
  register uint8_t checksum = 0;
  while (count--) {
    checksum += *data_ptr++;
  }
  return (-checksum); // -E> L:CHECKSUM
}

will add the special report tag safe to the violation reports for locations labelled by CHECKSUM.

The above code blocks provide examples of special comments. These comments which can be in the /* ... */ style or the BCPL // style are prefixed by -E and have two forms: tagged comments and location comments.

The format for tagged comments is as follows:

  • -E> TAG SERVICE EOS STRING

    • TAG: a report tag that is added to the associated violation report;

    • SERVICE:

      a -service_selector identifier or a matcher expression used to select the services to which the deviation applies;

    • EOS: end of scope, which takes one of two forms:

      :LABEL:

      a label used to mark the location up to which this comment applies;

      NUM:

      a non-negative number indicating the number of additional source-code lines below the current line to which this deviation applies.

    • STRING:

      the documentation.

A report that has the special tag hide is not shown.

The format for location comments is as follows:

  • -E> L:LABEL

    • :LABEL: marks the lines to which the comment applies.

A predefined location label :EOF refers to end of the current file

Note that the initial marker that identifies these special comments can have more than one leading dash: i.e., -E>, --E>, ---E>, … are all equivalent.

Note also that only tagging comments within source areas not skipped by the preprocessor are taken in account. For example, tagging comments within code regions delimited by #if 0 and #endif are ignored. This allows specifying conditional tagging.

This tagging procedure can be performed directly from the ECLAIR GUI using the Tagging comment feature (see Selected Reports Pages). This feature requires to establish a connection between eclair_report and a supported IDE or Editor (see Integrating ECLAIR with IDEs, Editors, and CI Tools).

The global configuration option remap_rtag defined in Global Options can rename a tag. With this option, the tag hide could be mapped to another tag such as low_priority; these reports would then be displayed. Alternatively, the special comments could be given unique tags and then a selected subset of these could be remapped to hide, thereby selectively hiding the associated reports.

Metrics

The chapter lists all the metrics supported by this release of ECLAIR. For each metric, we include

  • a short summary of the metric: where the metric is based on an external source, this summarizes the metric as presented by that source;

  • a detailed description of the metric: this contains a best-effort interpretation of the metric letter and spirit, taking into account all the available, authoritative sources of information (note that we use here the terminology described in File portions and sources).

To apply these metrics, use the tools described in The BUGSENG Meters.

The Available Metrics

This section introduces all the software metrics that are supported by this release of ECLAIR.

The Language Standard Metrics

The section describes the available metrics used by the language standard rules (that is rules that are prefixed by STD.). The identifier for the ECLAIR metric also has the prefix STD..

Metric STD.ARG_CALL
Summary

Number of arguments in a function call.

Metric STD.ARG_MCALL
Summary

Number of arguments in a macro invocation.

Metric STD.BKIDCONT_BLOCK
Summary

Number of identifiers with block scope in a block.

Metric STD.BYTE_OBJ
Summary

Number of bytes in an object.

Metric STD.CASE_SWITCH
Summary

Number of case labels in a switch statement.

Description

Note that this count does not include default labels nor does it include case labels for any nested switch statements.

Metric STD.CHAR_STRING
Summary

Number of characters in a string.

Metric STD.CONST_ENUM
Summary

Number of constants in an enumerator.

Metric STD.CSELITNEST_MAX_FUNC
Summary

Maximum depth of nesting of compound/selection/iteration statements in a function.

Description

Counts, for each function, the maximum depth of nesting of block ({}), if, switch, for, while and do statements.

Metric STD.EXID_UNIT
Summary

Number of external identifiers in a unit.

Metric STD.EXPRNEST_MAX_PEXPR
Summary

Maximum depth of expression parentheses in a primary expression.

Description

A primary expression is an expression that is not a part of a larger expression.

Metric STD.INCLNEST_MAX_UNIT
Summary

Maximum depth of file #includes in a unit.

Metric STD.MACRO_UNIT
Summary

Number of macro identifiers in a unit.

Metric STD.MAXTYPE_DECL
Summary

Maximum number of pointer, array and function types in a function declaration.

Metric STD.MEMBER_REC
Summary

Number of member declarations in a struct or union.

Metric STD.PARAM_DEF
Summary

Number of macro parameters in a macro definition.

Metric STD.PPIFNEST_MAX_UNIT
Summary

Maximum depth of preprocessor conditionals in a unit.

Description

Counts the maximum depth of nesting of the preprocessor conditionals if, ifdef and ifndef in a unit.

Metric STD.RECNEST_MAX_PREC
Summary

Maximum depth of nesting of structs and unions.

Description

The metric is reported for primitive records; that is, records that are not themselves part of a containing record.

Metric STD.TYPENEST_MAX_PTYPE
Summary

Maximum depth of type parentheses.

Description

Counts the depth of nesting of type parentheses for each primitive type. Note that a primitive type is a type that is not part of a larger type.

The BUGSENG Metrics

This section describes the range of available ECLAIR metrics defined by BUGSENG. The identifier for the ECLAIR metric has the prefix B..

Metric B.ACPATH_FUNC
Summary

Number of acyclic paths through a function.

Description

The number computed by this metric is defined in [4].

Note that this metric does not count paths due to the presence of backward jumps or indirect gotos; in these cases the results are unreliable.

Metric B.ALLSTMTS_FUNC
Summary

Total number of statements in a function.

Description

For this measure a statement in the source is counted if it is:

  • a do, for, for_range, while, switch, ms_dependent_exists, try, catch, seh_except, seh_finally or seh_try statement;

  • an initialized declaration in a decl_stmt

  • or a simple statement followed by a ;.

Metric B.BLOCKNEST_FUNC
Summary

Depth of nesting of blocks in a function.

Metric B.CALLER_PROG
Summary

Number of functions calling a function in a program.

Metric B.CALL_FUNC
Summary

Number of direct and indirect function calls in a function.

Description

Note that only explicit calls are counted so that constructor calls, implicit calls to destructor or calls to new or delete operators are not counted.

Metric B.CALL_UNIT
Summary

Number of direct and indirect function calls in a unit.

Description

Note that only explicit calls are counted so that constructor calls, implicit calls to destructor or calls to new or delete operators are not counted.

Metric B.CHAR_LINE
Summary

Number of characters in a logical source line.

Metric B.CMNTLINE_JFUNC
Summary

Number of non-empty comment lines in a function in the project.

Description
  • All declared functions (that is, all methods, constructors, conversions, and destructors) explicitly written in the project source are checked. The counted comments for a function (declaration or definition) are:

    • Comments immediately preceding the declaration, where immediately preceding means that the next non-comment character is the first character of the declaration or definition and that the nearest preceding non-comment character is stricly above the first line of the comment.

    • Comments within the declaration.

    • Any comment that begins on the same line as the last character of the declaration.

  • Only comments lines that include a word character are counted.

  • No comment is counted more than once. This means that, for example, if there is a nested function definition, the comments associated to the nested function are ignored by the enclosing function.

  • The comment selector metric_func_ignored_comments (see the -comment_selector) may be used to select the comments that should be ignored.

For example with:

-comment_selector={metric_func_ignored_comments, "^/\\*\\..*$"}

in the configuration, ECLAIR comments beginning with /*. will not be counted.

Metric B.COMF_JFUNC
Summary

Comment density in a function in the project.

Description

The ratio of comment lines and the number of statements in a function.

The comment selector metric_main_file_ignored_comments (see the -comment_selector) may be used to select the comments that should be ignored. For example with:

-comment_selector={metric_main_file_ignored_comments, "^/\\*\\..*$"}

in the configuration, ECLAIR comments beginning with /*. will not be counted.

Metric B.COMMENT_FUNC
Summary

Number of comments in a function.

Description

This includes any comment immediately preceding the function definition.

The comment selector metric_func_ignored_comments (see the -comment_selector) may be used to select the comments that should be ignored. For example with:

-comment_selector={metric_func_ignored_comments, "^/\\*\\..*$"}

in the configuration, ECLAIR comments beginning with /*. will not be counted.

Metric B.EXID_PROG
Summary

Number of external identifiers in a program.

Metric B.HARRISON_FUNC
Summary

Harrison’s Complexity Metric.

Description

Harrison’s complexity metric is defined by W. A. Harrison in [18].

Metric B.IFNEST_PIF
Summary

Depth of nesting of if statements.

Description

Counts the depth of nesting of an if statement within a primitive if. Note that a primitive if is an if statement that is not a part of a larger if statement.

Metric B.LINES_FILE
Summary

Number of physical lines in a file.

Metric B.LINES_FUNC
Summary

Number of physical lines in a function.

Metric B.LOGBOP_FUNC
Summary

Number of && and || operators in a function.

Metric B.LSLOCS_BLOCK
Summary

Number of logical source lines of code in a block.

Description

Notes:

  • each declaration and each statement is counted as one logical source line of code so that a single logical statement that extends over five physical lines counts as one line;

  • if more than one declaration or statement is on a physical line, then each statement is counted separately;

  • comments (whole or embedded) and blank lines are not counted.

Metric B.LSLOCS_FUNC
Summary

Number of logical source lines of code in a function.

Description

Notes:

  • each declaration and each statement is counted as one logical source line of code so that a single logical statement that extends over five physical lines counts as one line;

  • if more than one declaration or statement is on a physical line, then each statement is counted separately;

  • comments (whole or embedded) and blank lines are not counted.

Metric B.LSLOCS_JFUNC
Summary

Number of logical source lines of code in a function in the project.

Description

The number of logical source lines of code for a function in a project.

Notes: it aggregates the results obtained by the metric B.LSLOCS_FUNC for each function entity in the project.

Metric B.MCCABE_FUNC
Summary

McCabe’s original Complexity Metric.

Description

The McCabe’s complexity measure is defined by T. J. McCabe in [25].

Metric B.NAMED_PARAM_FUNC
Summary

Number of named function parameters in a function definition.

Metric B.NOELSE_FUNC
Summary

Number of if-else-if without an else in a function.

Description

Counts the number of if statements with an else if construct that have no final else clause.

Metric B.NPATH_FUNC
Summary

Number of npaths through a function.

Description

The metric measures NPATH as defined by B. J. Nejmeh in [26].

It does not count paths due to the presence of backward jumps or indirect gotos, and in these cases the results are unreliable

Metric B.PARAM_FUNC
Summary

Number of parameters in a function definition.

Metric B.RETPOINTS_FUNC
Summary

Number of return points in a function.

Description

Counts the number of return points in a function.

Note that the metric counts all return statements and any implicit return point at the end of a function. For instance, B.RETPOINTS_FUNC is 2 for the following function:

int a;

void f(int x) {
  if (x == 5) {
    a = 2;
    return;
  }
  else {
    a = 3;
  }
}

The metric does not consider the reachability of the return points.

Metric B.SEMI_BLOCK
Summary

Number of statement-like language constructs in a block.

Description

The number of non-compound statements (that is, excluding statements such as for and switch that may include other statements) in a block.

More precisely, the number of statements is the number of semicolons except for the following instances:

  • within for expressions,

  • within struct or union declarations/definitions,

  • within comments,

  • within literals,

  • within preprocessor directives,

  • within old-style C function parameter lists.

Metric B.STATL_FUNC
Summary

Number of references to local statically-allocated variables in a function.

Metric B.STATNL_FUNC
Summary

Number of references to non-local statically-allocated variables in a function.

Metric B.STBAK_FUNC
Summary

Number of back jumps in a function.

Description

A back jump is when a goto statement refers to a label earlier in the source code.

Note that an indirect goto statement is counted if any label occurs earlier in the source code.

Metric B.STCYC_FUNC
Summary

McCabe’s Complexity Metric.

Description

The function’s complexity is M - L - L1 where:

  • M is the complexity as defined by T. J. McCabe in [25];

  • L is the number of logical && and || operators; and

  • L1 is the number of ternary ? : operators

Metric B.STFCO_UNIT
Summary

A count of the function coupling in a translation unit.

Description

A count of the function coupling in a translation unit.

The “estimated function coupling” is a translation unit metric defined as the sum of function calls for each function defined in the unit, minus B.STFNC_UNIT, plus 1.

The resulting value can be negative.

See [9] and [12].

Metric B.STFNC_UNIT
Summary

The number of function definitions in a translation unit.

Description

A count of function definitions in a translation unit. This is used by B.STFCO_UNIT to estimate the degree of function coupling in a translation unit (see [9] and [12]).

Metric B.STGTO_FUNC
Summary

Number of goto statements in a function.

Description

Both direct and indirect goto statements are counted.

Metric B.STM22_UNIT
Summary

Number of statement-like language constructs in a translation unit.

Description

The number of statements is the number of semicolons except for the following instances:

  • within for expressions,

  • within struct or union declarations/definitions,

  • within comments,

  • within literals,

  • within preprocessor directives,

  • within old-style C function parameter lists.

Metric B.STM28_UNIT
Summary

Number of comments in the main file of a translation unit.

Description

For each translation unit, a count of all comments in the main file, except for those that precede:

  • the first code token,

  • the first preprocessor directive token.

Multiple comments separated by white space are counted together as a single comment.

The comment selector metric_main_file_ignored_comments (see the -comment_selector) may be used to select the comments that should be ignored. For example with:

-comment_selector={metric_main_file_ignored_comments, "^/\\*\\..*$"}

in the configuration, ECLAIR comments beginning with /*. will not be counted.

Metric B.STMIF_FUNC
Summary

Depth of nesting of iteration and selection statements.

Description

The maximum depth of nesting of if, switch, for, while and do statements in a function.

Metric B.STMT_HARRISON_FUNC
Summary

Statement-only variant of Harrison’s Complexity Metric.

Description

The function’s complexity is M - L where:

  • M is the complexity as defined by W. A. Harrison in [18] and

  • L is the number of logical && and || operators.

Metric B.STRET_FUNC
Summary

Number of return points in a function.

Description

Counts the number of reachable return statements in a function. Notes:

  • this metric only counts return statements and does not count any implicit return point at the end of a function;

  • as this metric checks the reachability of the return statements, the results may be unreliable in the presence of back jumps.

Metric B.STST1_FUNC
Summary

Number of statements in a function.

Description

For this measure a statement in the source is counted if it is:

  • a null, decl, compound, case, default, label, do, for, for_range, while, switch, ms_dependent_exists, try, catch, seh_except, seh_finally or seh_try statement;

  • or a simple statement followed by a ;.

It is not counted if it is in the context of a statement expression.

Metric B.STST2_FUNC
Summary

Number of statements except block, empty statements and labels in a function.

Description

For this measure a statement in the source is counted if it is:

  • a decl, do, for, for_range, while, switch, ms_dependent_exists, try, catch, seh_except, seh_finally or seh_try statement;

  • or a simple statement followed by a ;.

It is not counted if it is in the context of a statement expression.

Metric B.STST3_FUNC
Summary

Number of statements except block, empty statements, labels and declarations in a function.

Description

For this measure a statement in the source is counted if it is:

  • a do, for, for_range, while, switch, ms_dependent_exists, try, catch, seh_except, seh_finally or seh_try statement;

  • an initialized declaration in a decl_stmt

  • or a simple statement followed by a ;.

It is not counted if it is in the context of a statement expression.

Metric B.STSUB_FUNC
Summary

Number of function calls in a function.

Description

Note that only explicit calls are counted so that constructor calls, implicit calls to destructor or calls to new or delete operators are not counted.

See [9] and [12].

Metric B.STXLN_FUNC
Summary

The number of executable lines of code in a function.

Description

An executable line of code is a line that contains a token that is not:

  • a comment,

  • a declaration unless it contains an initializer, or

  • a brace.

Note that the above definition of executable lines of code applies to code after preprocessing and does not apply to function templates.

Metric B.VOCF_FUNC
Summary

The VOCF language scope metric.

Description

For each unit, the value is the ratio (N1 + N2) / (nl + n2) where

  • n1: is the number of distinct operators;

  • n2: is the number of distinct operands;

  • N1: is the total number of operators;

  • N2: is the total number of operands;

where operands are:

  • literals: integer, character, string, float;

  • all identifiers that are not reserved words;

  • the builtin types;

  • asm and this;

and operators are:

  • if, else, while, do while return, for, switch, break, continue, goto;

  • bracket pairs (), [], {} (except when used for the operators listed above);

  • binary and unary operators: arithmetic, assignment, logical, bitwise, member access, sizeof, shift, increment/decrement, comma and conditional expression ?: (counted as a single element);

  • ; (semicolon) (except in a for statement);

  • declarative operators (e.g. typedef);

  • most reserved words except asm, this and builtin types;

  • preprocessor directives.

The HIS Metrics

The section describes the available HIS Source Code Metrics [13]. Note that for each of the supported HIS Source Code Metrics, the identifier for the corresponding ECLAIR service is obtained by adding the prefix HIS. .

Note that the page numbers included in the references to [13] in the ECLAIR metric summaries are for the PDF version of [13] .

Metric HIS.CALLING
Summary

Number of calling functions. (See page 5 of HIS-SCM-2008 [13] .)

Description

The metric is not reported when the function

  • has no location in the source code, or

  • is a pattern and not fully instantiated.

The location for functions such as implicit constructors, conversions and destructors is the location of the class declaration and hence these will only have locations if the class itself is in the source code.

Metric HIS.CALLS
Summary

Number of called functions. (See page 5 of HIS-SCM-2008 [13] .)

Description

In each function definition, a count of the directly called functions (where multiple calls to the same function is counted once).

Note that only explicit calls are counted so that constructor calls, implicit calls to destructor or calls to new or delete operators are not counted.

Metric HIS.COMF
Summary

Comment density. (See page 5 of HIS-SCM-2008 [13] .)

Description

The ratio of comments compared to number of statements in the main file. That is, to ensure that the value is less than or equal to 1:

  • when the number of comments is 0, the value is 0;

  • when the number of comments is greater than the number of statements, the value is 1;

  • otherwise, the value is the ratio of the number of comments compared to the number of statements.

Note that, for this measure, a statement is counted unless it is:

  • a block statement (that is {...}),

  • a null statement,

  • a goto label,

  • a case or default label, or

  • a declaration statement.

The comment selector metric_main_file_ignored_comments (see the -comment_selector) may be used to select the comments that should be ignored. For example with:

-comment_selector={metric_main_file_ignored_comments, "^/\\*\\..*$"}

in the configuration, ECLAIR comments beginning with /*. will not be counted.

Metric HIS.GOTO
Summary

Number of goto statements. (See page 5 of HIS-SCM-2008 [13] .)

Description

Both direct and indirect goto statements are counted.

Metric HIS.LEVEL
Summary

Depth of nesting of a function. (See page 6 of HIS-SCM-2008 [13] .)

Description

The maximum depth of nesting of if, switch, for, while and do statements in a function.

Metric HIS.PARAM
Summary

Number of function parameters. (See page 6 of HIS-SCM-2008 [13] .)

Metric HIS.PATH
Summary

Number of paths. (See page 5 of HIS-SCM-2008 [13] .)

Description

A rough estimate of the number of acyclic execution paths through each function corresponding to the NPATH metric as defined by B. J. Nejmeh in [26]. Notes:

  • this metric does not count paths due to the presence of backward jumps or indirect gotos, and in these cases the results are unreliable;

  • as explained in depth in [4], despite the fact that the declared NPATH objective is to count the number of acyclic execution paths through a function, its definition for the C language fails to do so even for very simple programs. Unless you have a requirement to use the specification in page 5 of HIS Source Code Metrics [13] , we recommend using B.ACPATH_FUNC instead.

Metric HIS.RETURN
Summary

Number of return points. (See page 6 of HIS-SCM-2008 [13] .)

Description

The number of return statements in a function in the preprocessed sources. Notes:

  • this metric complies with the (imprecise) specification on page 6 of HIS Source Code Metrics [13] whereby the number of return statements have to be counted and not the return points. For instance, HIS.RETURN is 1 for the following function:

int a;

void f(int x) {
  if (x == 5) {
    a = 2;
    return;
  }
  else {
    a = 3;
  }
}
  • Nonetheless, the function has 2 return points, which is the value of the B.RETPOINTS_FUNC metric. Unless you have a requirement to use the specification on page 6 of HIS Source Code Metrics [13] , we recommend using B.RETPOINTS_FUNC instead.

Metric HIS.STMT
Summary

Number of instructions per function. (See page 6 of HIS-SCM-2008 [13] .)

Description

For this measure a statement in the source is counted if it is:

  • a do, for, for_range, while, switch, ms_dependent_exists, try, catch, seh_except, seh_finally or seh_try statement;

  • an initialized declaration in a decl_stmt

  • or a simple statement followed by a ;.

It is not counted if it is in the context of a statement expression.

Metric HIS.VOCF
Summary

Language scope. (See page 7 of HIS-SCM-2008 [13] .)

Description

For each function, the value is the ratio (N1 + N2) / (nl + n2) where

  • n1: is the number of distinct operators;

  • n2: is the number of distinct operands;

  • N1: is the total number of operators;

  • N2: is the total number of operands;

where operands are:

  • literals: integer, character, string, float;

  • all identifiers that are not reserved words;

  • the builtin types;

  • asm and this;

and operators are:

  • if, else, while, do while return, for, switch, break, continue, goto;

  • bracket pairs (), [], {} (except when used for the operators listed above);

  • binary and unary operators: arithmetic, assignment, logical, bitwise, member access, sizeof, shift, increment/decrement, comma and conditional expression ?: (counted as a single element);

  • ; (semicolon) (except in a for statement);

  • declarative operators (e.g. typedef);

  • most reserved words except asm, this and builtin types;

  • preprocessor directives.

Metric HIS.ap_cg_cycle
Summary

Number of recursions. (See page 7 of HIS-SCM-2008 [13] .)

Description

The number of direct and indirect recursions in the call graph.

Indirect recursions count is obtained counting the number of non-singleton strongly connected components in the call graph.

Metric HIS.v_G
Summary

Cyclomatic complexity. (See page 5 of HIS-SCM-2008 [13] .)

Description

The metric gives a measure of a function’s complexity, where complexity is as defined by T. J. McCabe in [25] and computed using the shortcut formula number of binary decisions + 1.

Source Code Formatting

Note

The ECLAIR source code formatting functionality described in this chapter, differently from all other ECLAIR components, has the potential to modify the application source code. For this reason, this functionality is not qualifiable for use in safety-related development. In addition, we recommend against routinely reformatting the code: please make sure that you do not skip the instructions on proper use of eclair_format contained in this chapter.

The eclair_format provides formatting for C or C++ source code according to coding style guidelines. Currently, only the code layout guidelines in BARR-C:2018 [8] are supported.

Invocation of eclair_format

The program can be invoked according to the following syntax:

eclair_format [options] <files>

where <files> is a sequence of one or more source code files to be formatted.

Available eclair_format Options

Option -c
-c

do not change the files: only check whether formatting would change them;

Option -i
-i <DEPTH>

set <DEPTH>, the indentation depth, to be either 2 or 4 (default);

Option -l
-l <LANGUAGE>

set <LANGUAGE>, the source language, to be either C (default) or C++ (the lowercase variants are accepted as well);

Option -s
-s <STYLE>

set <STYLE>, the formatting style, to be NC3 (default, denoting BARR-C:2018 [8]), the only option currently available;

Option -v
-v

display version information on stderr and continue;

Option -h
-h

display help text on stderr and exit.

Limitations of eclair_format

The eclair_format program has been designed to aid reformatting existing code aiming at high quality and high readability. For these reasons, it will fail or generate poor output when, e.g., the preprocessor is used in “creative” ways or when extremely long expressions are present in the input source code. Other specific limitations are:

  • declarations with more than one declarator (e.g., int *f(void), g(int z)) are not supported (but they are banned by BARR-C:2018 Rule 8.1.a);

  • declarations containing more than three levels of pointer indirections (e.g., int ****p, which contains four) are not supported (note, though, that a limit of two levels of pointer indirections is set by MISRA C:2012 Rule 18.5).

Proper Use of eclair_format

While it is technically possible to reformat source code automatically after any change, this is not recommended. Particularly for critical applications, it is crucial that developers do see and reason upon the actual code that is compiled. No matter how small the chance that eclair_format might insert a defect in the source code, this risk must not be ignored, even in programming languages such as C and C++ that are largely whitespace-insensitive. In particular:

  • even though eclair_format has been designed to not change string literals, there are no strict guarantees in this respect;

  • C/C++ language extensions such as those allowing the embedding of assembly code in C/C++ source code might have whitespace-sensitive syntactic elements and eclair_format may mess around with them.

In order to mitigate the latter potential problem, developers can delimit code areas by means of special comments beginning with one blank space and then continuing with *ECLAIR_FORMAT-OFF* and *ECLAIR_FORMAT-ON*: any code between these comments will not be touched by eclair_format. For example:

void foo{void) {
  /* *ECLAIR_FORMAT-OFF* */
#pragma asm
  JMP   $  ; endless loop
#pragma endasm
  /* *ECLAIR_FORMAT-ON* */
}

The recommended way to use eclair_format is to bring an existing code base into near compliance with the code layout guidelines in BARR-C:2018 doing the following:

  1. Before using eclair_format, compile the project and then, for each translation unit, archive the generated object file.

  2. Use eclair_format on each source code file.

  3. Recompile the project and compare the newly generated object files with the archived ones. In case of discrepancy, restore the affected original source file and see whether use of comments *ECLAIR_FORMAT-OFF* and *ECLAIR_FORMAT-ON* may help or if the whole file must be excluded from the application of eclair_format.

  4. If there are no changes, then keep complying with the code layout guidelines while you add or modify code, refraining from further use of eclair_format: use the ECLAIR services for BARR-C:2018 to detect violations and then fix them manually.

Requirements Management with ECLAIR

Requirements Management Tool

Note

The ECLAIR requirements management tool is derived from the open-source StrictDoc tool. The reasons why, in the ECLAIR Software Verification Platform, this functionality is available under the eclair_reqman program (instead of strictdoc as the original) are the following:

  1. BUGSENG takes responsibility for the tool in front of its customers by providing support and maintenance services.

  2. For these purposes, BUGSENG may have to deviate from the open-source project, so that eclair_reqman may be (slightly) different from any published version of StrictDoc.

  3. As the responsibility for deviation from the open-source project should rest on BUGSENG only and not be reflected on the open-source project, we refer to the tool as the “ECLAIR requirements management tool” and call the executable eclair_reqman.

Said that, BUGSENG intends to keep the deviations from StrictDoc at the bare minimum so that, unless specified otherwise, a user can switch to the original open-source distribution (available from GitHub) and have the same functionality. The rest of this chapter is taken, almost verbatim, from StrictDoc documentation.

StrictDoc is software for writing technical requirements and specifications.

Summary of StrictDoc features:

  • The documentation files are stored as human-readable text files.

  • A simple domain-specific language DSL is used for writing the documents. The text format for encoding this language is called SDoc (strict-doc).

  • StrictDoc reads *.sdoc files and builds an in-memory representation of a document tree.

  • From this in-memory representation, StrictDoc can generate the documentation into a number of formats including HTML, RST, ReqIF, PDF, Excel.

  • StrictDoc has a web-based user interface which allows viewing and editing the documents and requirements. The changes are written back to .sdoc files.

  • The focus of the tool is modeling requirements and specifications documents. Such documents consist of multiple statements like “system X shall do Y” called requirements.

  • The requirements can be linked together to form the relationships, such as “parent-child”. From these connections, many useful features, such as Requirements Traceability and Documentation Coverage, can be derived.

  • Requirements to source files traceability (experimental). See Traceability between requirements and source code.

  • Custom grammar and custom fields support. The StrictDoc’s grammar can be extended to support arbitrary special fields, such as PRIORITY, OWNER, or even more specialized fields, such as Automotive Safety Integrity Level (ASIL) or Verification method. See Custom grammars.

  • Good performance of the textX parser and parallelized incremental generation of documents: generation of document trees with up to 2000–3000 requirements into HTML pages stays within a few seconds. From the second run, only changed documents are regenerated. Further performance tuning should be possible.

Examples

Hello World

“Hello World” example of the SDoc text language:

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]
UID: SDOC-HIGH-REQS-MANAGEMENT
TITLE: Requirements management
STATEMENT: StrictDoc shall enable requirements management.

Create a file called hello_world.sdoc somewhere on your file system and copy the above “Hello World” example text to it. The file must end with a newline character.

Open a command-line terminal program supported on your system.

Once you have eclair_reqman installed, switch to the directory with the hello_world.sdoc file. For example, assuming that the file is now in the workspace/hello_world directory in your user folder:

cd <your user home directory>/workspace/hello_world

Run eclair_reqman as follows:

eclair_reqman export hello.sdoc

The expected output:

$ eclair_reqman export hello.sdoc
Parallelization: Enabled
Step 'Collect traceability information' start
Step 'Find and read SDoc files' start
Reading SDOC: hello.sdoc .................................... 0.08s
Step 'Find and read SDoc files' took: 0.09 sec
Step 'Collect traceability information' start
Step 'Collect traceability information' took: 0.01 sec
Step 'Collect traceability information' took: 0.11 sec
Published: StrictDoc ........................................ 0.24s
...
Export completed. Documentation tree can be found at:
.../output/html

The HTML output produced so far has been generated statically. Now, start a StrictDoc server from the same directory:

eclair_reqman server .

The expected output should contain the following line:

INFO:     Uvicorn running on http://127.0.0.1:5111 (Press CTRL+C to quit)

Open the URL in the browser and explore the contents of the example.

StrictDoc Examples repository

The strictdoc-examples repository contains a collection of basic examples. Visit the repository and read its README for details.

StrictDoc Templates repository

The strictdoc-templates repository contains a growing collection of templates from the industry standards like DO-178C (aviation) and ECSS-E-ST-40C (space).

Other examples

For a more comprehensive example, check the source file of this documentation which is written using StrictDoc: strictdoc_01_user_guide.sdoc.

Running StrictDoc

Static HTML export

The easiest way to see the static HTML export feature in action is to run the Hello World example.

The export command is the main producer of documentation. The native export format of StrictDoc is HTML. The export command supports a number of parameters, including the option for selecting export formats (HTML, RST, Excel, etc.). The options can be explored with the --help command.

eclair_reqman export --help
Web server

StrictDoc supports a web-based user interface. The StrictDoc web server is launched via the server command which accepts a path to a documentation tree as a parameter.

eclair_reqman server .

The server command accepts a number of options. To explore the options, run:

eclair_reqman server --help
Limitations of web user interface

Note: The implementation of the web interface is work-in-progress. See Limitations of the web ser interface for an overview of the existing limitations.

Security considerations

TL;DR StrictDoc’s web server is not yet hardened against unsafe use. Making StrictDoc safe for deployment in public networks is an ongoing effort.

Using StrictDoc’s command-line and web interfaces should be more secure if the web server is not deployed on a public network.

Due to current constraints (refer to Limitations of web user interface), StrictDoc requires running a server through a command line interface in one window or OS process, and separately committing changes to documents using Git in another window or OS process. Deploying StrictDoc as a shared web server is impractical, as it still requires manual commits to SDoc files via the server’s command line using Git. The future development plan for StrictDoc aims to enable its use as a standalone server application, which includes resolving the following security-related issues.

What makes StrictDoc’s web server unsafe:

  • The web interface is not fully hardened against unsafe inputs, such as malformed strings or files. The web server does not perform comprehensive sanity checks on the size and validity of inputs across all its HTTP endpoints.

  • StrictDoc uses the pickle module to cache SDoc files, significantly improving performance. However, the pickle module is not secure. The pickled files are currently stored in the /tmp folder, which poses risks under certain circumstances.

  • The security-related properties of the textX/Arpeggio parser are not understood yet. We have opened a request to track this upstream: textX - Security considerations (#422).

  • Several uses of regular expressions may be unsafe, some of which have been identified by GitHub’s CodeQL analyzer.

  • The security aspects of StrictDoc’s dependencies have not yet been analyzed.

Known security-related issues are tracked on GitHub, under the “Security” label. As StrictDoc becomes usable without command-line access, all known issues will need to be addressed or acknowledged as known limitations.

We are committed to continuously enhancing the functionality and security of StrictDoc and welcome user feedback and contributions in this area.

IDE support

StrictDoc language markup (SDoc) can be activated in all IDEs that support the TextMate grammars. When the StrictDoc grammar is integrated into an IDE, the SDoc syntax becomes highlighted just as any other syntax like Markdown, RST, Python, etc.

The TextMate grammars can be defined in either JSON or PLIST formats. The Sublime Text’s Syntax is similar to the TextMate grammar but has more capabilities and is no longer backward-compatible with both TextMate’s JSON and PLIST grammars.

The following IDEs are known to work:

  • Microsoft Visual Studio Code (TextMate JSON)

  • JetBrains’s PyCharm and WebStorm (TextMate JSON). The other JetBrains IDEs are expected to work too.

  • Eclipse (TextMate JSON)

  • Sublime Text (Sublime Syntax)

Due to the incompatibilities between these formats, the markup files are provided in separate repositories:

The instructions for installing the StrictDoc markup can be found in all repositories.

For any other IDE, when possible, it is recommended to use the TextMate JSON format, unless a given IDE is known to only support the TextMate bundle format (.tmbundle). The exception is Sublime Text which has its own format.

Note: The TextMate grammar and the Sublime Syntax for StrictDoc only provides syntax highlighting. More advanced features like autocompletion and deep validation of requirements can be only achieved with a dedicated Language Server Protocol (LSP) implementation for StrictDoc. The StrictDoc LSP is on StrictDoc’s long-term roadmap, see Enhancement: Language Protocol Server for SDoc text language #577.

SDoc syntax

StrictDoc defines a special syntax for writing specifications documents. This syntax is called SDoc and it’s grammar is encoded with the textX tool.

The grammar is defined using textX language for defining grammars and is located in a single file: grammar.py.

This is how a minimal possible SDoc document looks like:

[DOCUMENT]
TITLE: StrictDoc

This documentation is written using StrictDoc. Here is the source file: strictdoc_01_user_guide.sdoc.

Document structure

An SDoc document consists of a [DOCUMENT] declaration followed by one or many [REQUIREMENT] or [COMPOSITE_REQUIREMENT] statements which can be grouped into [SECTION] blocks.

The following grammatical constructs are currently supported:

  • DOCUMENT

    • FREETEXT

  • REQUIREMENT and COMPOSITE_REQUIREMENT

  • SECTION

    • FREETEXT

Each construct is described in more detail below.

Strict rule #1: One empty line between all nodes

StrictDoc’s grammar requires each node, such as [REQUIREMENT], [SECTION], etc., to be separated with exactly one empty line from the nodes surrounding it. This rule is valid for all nodes. Absence of an empty line or presence of more than one empty line between two nodes will result in an SDoc parsing error.

Strict rule #2: No content is allowed outside of SDoc grammar

StrictDoc’s grammar does not allow any content to be written outside of the SDoc grammatical constructs. It is assumed that the critical content shall always be written in form of requirements: [REQUIREMENT] and [COMPOSITE_REQUIREMENT]. Non-critical content shall be specified using [FREETEXT] nodes. By design, the [FREETEXT] nodes can be only attached to the [DOCUMENT] and [SECTION] nodes.

Strict rule #3: No empty strings

StrictDoc’s grammar does not allow empty strings. This rule is applicable to both single-line and multiline strings and both section fields and requirement fields. A field is either missing or is a non-empty string.

The following patterns are all invalid for single-line fields:

[SECTION]
TITLE:

[SECTION]
TITLE: (any number of space characters after colons)

[REQUIREMENT]
STATEMENT:

[REQUIREMENT]
STATEMENT: (any number of space characters after colons)

The following patterns are all invalid for multiline fields:

[REQUIREMENT]
COMMENT: >>>
<<<

[REQUIREMENT]
COMMENT: >>>
(any number of space characters)
<<<

If you need to provide a placeholder for a field that you know has to be filled out soon, add a “TBD” (to be done, by our team) or a “TBC” (to be confirmed with a customer or a supplier) string.

The Project Statistics screen provides metrics for counting the number of TBDs (To Be Determined) and TBCs (To Be Confirmed) in a document, assisting in evaluating the document’s maturity. This is a common practice in the regulared industries. See Project statistics screen for more details.

Grammar elements
Document

The [DOCUMENT] element must always be present in an SDoc document. It is a root of an SDoc document graph.

[DOCUMENT]
TITLE: StrictDoc
(newline)

The following DOCUMENT fields are allowed:

SDoc grammar DOCUMENT fields

Field

Description

TITLE

Title of the document (mandatory)

UID

Unique identifier of the document

VERSION

Current version of the document

CLASSIFICATION

Security classification of the document, e.g. Public, Internal, Restricted, Confidential

ROOT

Defines whether a document is a root object in a traceability graph. A root document is assumed to not have any parent requirements. The project statistics calculation will skip all root document’s requirements when calculating the metric Non-root-level requirements not connected to any parent requirement.

OPTIONS

Document configuration options

The DOCUMENT declaration must always have a TITLE field. The other fields are optional. The OPTIONS field can be used for specifying the document configuration options. Note: The sequence of the fields is defined by the document’s Grammar, i.e. should not be changed.

Finally an optional [FREETEXT] block can be included.

[DOCUMENT]
TITLE: StrictDoc
OPTIONS:
  REQUIREMENT_STYLE: Table

[FREETEXT]
StrictDoc is software for writing technical requirements and specifications.
[/FREETEXT]
Document configuration options

The OPTIONS field may have the following attribute fields:

SDoc grammar DOCUMENT-OPTIONS fields

Field

Attribute values

ENABLE_MID

False (default), True

MARKUP

RST (default), HTML, Text

AUTO_LEVELS

On (default), Off

REQUIREMENT_STYLE

Inline (default), Table, Zebra

REQUIREMENT_IN_TOC

True (default), False

ENABLE_MID

See Machine identifiers (MID).

MARKUP

The MARKUP option controls which markup renderer will be used. The available options are: RST, HTML and Text. Default is RST.

AUTO_LEVELS

The AUTO_LEVELS option controls StrictDoc’s system of automatic numbering of the section levels. The available options are: On / Off. Default is On.

In case of On, the [SECTION].LEVEL fields must be absent or may only contain None to exclude that section from StrictDoc’s automatic section numbering. See also Section without a level.

In case of Off, all [SECTION].LEVEL fields must be populated.

REQUIREMENT_STYLE

The REQUIREMENT_STYLE option controls whether requirement’s elements are displayed inline or as table blocks. The available options are: - Inline - Table - Zebra

Default is Inline.

[DOCUMENT]
TITLE: Hello world
OPTIONS:
  REQUIREMENT_STYLE: Inline
REQUIREMENT_IN_TOC

The REQUIREMENT_IN_TOC option controls whether requirement’s title appear in the table of contents (TOC). The available options are: True / False. Default is True.

[DOCUMENT]
TITLE: Hello world
OPTIONS:
  REQUIREMENT_IN_TOC: True
Requirement

Minimal “Hello World” program with 3 empty requirements:

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]

[REQUIREMENT]

[REQUIREMENT]

The following REQUIREMENT fields are supported:

SDoc grammar REQUIREMENT fields

Field

Description

UID

Unique identifier of the requirement

LEVEL

Define section/requirement Level numbering

STATUS

Status of the requirement, e.g. Draft, Active, Deleted

TAGS

Tags of the requirement (comma separated AlphaNum words)

TITLE

Title of the requirement

STATEMENT

The statement of the requirement. The field can be single-line or multiline.

RATIONALE

The rationale of the requirement. The field can be single-line or multiline.

COMMENT

Comments to the rationale. The field can be single-line or multiline. Note: Multiple comment fields are possible.

RELATIONS

List of requirement relations. Note: Before StrictDoc v0.0.45, this field was called REFS.

Currently, all [REQUIREMENT]’s fields are optional but most of the time at least the STATEMENT field as well as the TITLE field should be present.

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]
TITLE: Requirements management
STATEMENT: StrictDoc shall enable requirements management.
UID

Unique identifier of the requirement.

Observation: Some documents do not use unique identifiers which makes it impossible to trace their requirements to each other. Within StrictDoc’s framework, it is assumed that a good requirements document has all of its requirements uniquely identifiable, however, the UID field is optional to accommodate for documents without connections between requirements.

StrictDoc does not impose any limitations on the format of a UID. Examples of typical conventions for naming UIDs:

  • REQ-001, SCA-001 (scalability), PERF-001 (performance), etc.

  • cES1008, cTBL6000.1 (example from NASA cFS requirements)

  • Requirements without a number, e.g. SDOC-HIGH-DATA-MODEL (StrictDoc)

  • SAVOIR.OBC.PM.80 (SAVOIR guidelines)

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]
UID: SDOC-HIGH-DATA-MODEL
STATEMENT: STATEMENT: StrictDoc shall be based on a well-defined data model.
Level

Also a [REQUIREMENT] can have no section level attached to it. To enable this behavior, the field LEVEL has to be set to None.

Status

Defines the current status of the [REQUIREMENT], e.g. Draft, Active, Deleted.

Tags

Allows to add tags to a [REQUIREMENT]. Tags are a comma separated list of single words. Only Alphanumeric tags (a-z, A-Z, 0-9 and underscore) are supported.

Relations (previously REFS)

The RELATIONS field is used to connect requirements to each other:

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]
UID: REQ-001
STATEMENT: StrictDoc shall enable requirements management.

[REQUIREMENT]
UID: REQ-002
TITLE: Requirement #2's title
STATEMENT: Requirement #2 statement
RELATIONS:
- TYPE: Parent
  VALUE: REQ-001
- TYPE: File
  VALUE: /full/path/file.py

The supported relation types are: Parent, Child, and File. To be used in a requirement, the relations must be first registered in the document grammar. The default grammar defines Parent and File relation. See Relations for more details.

The RELATIONS must be the last field of a requirement. For TYPE: Parent and TYPE: Child relations, the VALUE attribute contains a parent/child’s requirement UID. A requirement may reference multiple parent or child requirements by adding multiple TYPE/VALUE items. Defining circular references e.g. Req-AReq-BReq-CReq-A results in validation errors and must be avoided.

The TYPE: File-VALUE attribute contains a filename referencing the implementation of (parts of) this requirement. A requirement may add multiple file references requirements by adding multiple TYPE: File-VALUE items.

Note: The TYPE: Parent and TYPE: Child are currently the only fully supported types of connection. Linking requirements to files is still experimental (see also Traceability between requirements and source code).

Note: In most requirements projects, only the Parent relations should be used, possibly with roles. The Child relation should be used only in specific cases. See Parent vs Child relations for more details.

Note: In the near future, adding information about external references (e.g. company policy documents, technical specifications, regulatory requirements, etc.) is planned.

Note: By design, StrictDoc will only show parent or child links if both requirements connected with a reference have UID defined.

Requirement relation roles

A requirement relation can be specialized with a role. The role must be registered in the document grammar, see Relations.

[DOCUMENT]
TITLE: Example

[GRAMMAR]
ELEMENTS:
- TAG: REQUIREMENT
  FIELDS:
  ...
  RELATIONS:
  - TYPE: Parent
    ROLE: Refines

[REQUIREMENT]
UID: REQ-2
TITLE: Requirement title
STATEMENT: >>>
Requirement statement.
<<<
RELATIONS:
- TYPE: Parent
  VALUE: REQ-1
  ROLE: Refines
Title

The title of the requirement. Every requirement should have its TITLE field specified.

Observation: Many real-world documents have requirements with statements and titles but some documents only use statements without title in which case their UID becomes their TITLE and vice versa. Example:

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]
UID: REQ-001
STATEMENT: StrictDoc shall enable requirements management.
Statement

The statement of the requirement. The field can be single-line or multiline. Every requirement shall have its STATEMENT field specified.

Rationale

A requirement should have a RATIONALE field that explains/justifies why the requirement exists. Like comments, the rationale field can be single-line or multiline.

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]
UID: REQ-001
STATEMENT: StrictDoc shall enable requirements management.
COMMENT: Clarify the meaning or give additional information here.
RATIONALE: The presence of the REQ-001 is justified.
Comment

A requirement can have one or more comments explaining the requirement. The comments can be single-line or multiline.

[DOCUMENT]
TITLE: StrictDoc

[REQUIREMENT]
UID: REQ-001
STATEMENT: StrictDoc shall enable requirements management.
COMMENT: Clarify the meaning or give additional information here.
COMMENT: >>>
This is a multiline comment.

The content is split via \n\n.

Each line is rendered as a separate paragraph.
<<<
Section

The [SECTION] element is used for creating document chapters and grouping requirements into logical groups. It is equivalent to the use of #, ##, ###, etc., in Markdown and ====, ----, ~~~~ in RST.

[DOCUMENT]
TITLE: StrictDoc

[SECTION]
TITLE: High-level requirements

[REQUIREMENT]
UID: HIGH-001
STATEMENT: ...

[/SECTION]

[SECTION]
TITLE: Implementation requirements

[REQUIREMENT]
UID: IMPL-001
STATEMENT: ...

[/SECTION]
Nesting sections

Sections can be nested within each other.

[DOCUMENT]
TITLE: StrictDoc

[SECTION]
TITLE: Chapter

[SECTION]
TITLE: Subchapter

[REQUIREMENT]
STATEMENT: ...

[/SECTION]

[/SECTION]

StrictDoc creates section numbers automatically. In the example above, the sections will have their titles numbered accordingly: 1 Chapter and 1.1 Subchapter.

Free text

A section can have a block of [FREETEXT] connected to it:

[DOCUMENT]
TITLE: StrictDoc

[SECTION]
TITLE: Free text

[FREETEXT]
A sections can have a block of ``[FREETEXT]`` connected to it:

...
[/FREETEXT]

[/SECTION]

According to the Strict Rule #2, arbitrary content cannot be written outside of StrictDoc’s grammar structure. [SECTION] / [FREETEXT] is therefore a designated grammar element for writing free text content.

Note: Free text can also be called “nonnormative” or “informative” text because it does not contribute anything to the traceability information of the document. The nonnormative text is there to give a context to the reader and help with the conceptual understanding of the information. If a certain information influences or is influenced by existing requirements, it has to be promoted to the requirement level: the information has to be broken down into atomic [REQUIREMENT] statements and get connected to the other requirement statements in the document.

Section without a level

A section can have no level attached to it. To enable this behavior, the field LEVEL has to be set to None.

[DOCUMENT]
TITLE: Hello world doc

[SECTION]
TITLE: Section 1

[/SECTION]

[SECTION]
LEVEL: None
TITLE: Out-of-band Section

[/SECTION]

[SECTION]
TITLE: Section 2

[/SECTION]

The section with no level will be skipped by StrictDoc’s system of automatic numbering of the section levels (1, 1.1, 1.2, 2, …).

The behavior of the LEVEL: None option is recursive. If a parent section has its LEVEL set to None, all its subsections’ and requirements’ levels are set to LEVEL: None by StrictDoc automatically.

Composite requirement

A [COMPOSITE_REQUIREMENT] is a requirement that combines requirement properties of a [REQUIREMENT] element and grouping features of a [SECTION] element. This element can be useful in lower-level specifications documents where a given section of a document has to describe a single feature and the description requires a one or more levels of nesting. In this case, it might be natural to use a composite requirement that is tightly connected to a few related sub-requirements.

[COMPOSITE_REQUIREMENT]
STATEMENT: Statement

[REQUIREMENT]
STATEMENT: Substatement #1

[REQUIREMENT]
STATEMENT: Substatement #2

[REQUIREMENT]
STATEMENT: Substatement #3

[/COMPOSITE_REQUIREMENT]

Special feature of [COMPOSITE_REQUIREMENT]: like [SECTION] element, the [COMPOSITE_REQUIREMENT] elements can be nested within each other. However, [COMPOSITE_REQUIREMENT] cannot nest sections.

Note: Composite requirements should not be used in every document. Most often, a more basic combination of nested [SECTION] and [REQUIREMENT] elements should do the job.

Include files

StrictDoc .sdoc files can be built-up from including other fragment documents.

The [FRAGMENT_FROM_FILE] element can be used anywhere body elements can be used ( e.g. [SECTION], [REQUIREMENT], [COMPOSITE_REQUIREMENT] etc.) and will evaluate by inserting its contents from the file referenced by its FILE: property where it was used in the parent document. The files included must start with a [FRAGMENT] directive and cannot contain [FREETEXT] elements but are otherwise identical to *.sdoc files. They can have any filename except a .sdoc extension.

Here is an example pair of files similar to examples above. First the .sdoc file has a [FRAGMENT_FROM_FILE] that references the latter file.

[DOCUMENT]
TITLE: StrictDoc

[FREETEXT]
...
[/FREETEXT]

[FRAGMENT_FROM_FILE]
FILE: include.ssec

[REQUIREMENT]

Then the referenced file, include.ssec:

[FRAGMENT]

[REQUIREMENT]

[SECTION]
TITLE: Sub section
[/SECTION]

[COMPOSITE_REQUIREMENT]

[REQUIREMENT]

[/COMPOSITE_REQUIREMENT]

Which will resolve to the following document after inclusion:

[DOCUMENT]
TITLE: StrictDoc

[FREETEXT]
...
[/FREETEXT]

[REQUIREMENT]

[SECTION]
TITLE: Sub section
[/SECTION]

[COMPOSITE_REQUIREMENT]

[REQUIREMENT]

[/COMPOSITE_REQUIREMENT]

[REQUIREMENT]
Machine identifiers (MID)

StrictDoc supports the automatic generation of machine identifiers (MIDs). This optional feature can be enabled individually for each document through the document-level ENABLE_MID config option: .. code-block:

[DOCUMENT]
TITLE: Hello World!
OPTIONS:
  ENABLE_MID: True

When the ENABLE_MID option is enabled, StrictDoc automatically generates MID fields whenever the document is written back to the file system. On the web server, MIDs are generated automatically when a document, section, or requirement is saved. In the command-line interface, the generation of MID can be initiated with a passthrough command. Executing strictdoc passthrough on a document with ENABLE_MID: True results in all nodes having auto-generated MIDs. Implementing the ENABLE_MID option on a per-document basis allows for the integration of MID-enabled documents alongside third-party documents where the MID feature may not be necessary or desired.

Machine identifiers (MIDs) differ from and do not replace unique identifiers (UIDs). A requirement, section, or document node may have both MID and UID fields defined. For example:

[REQUIREMENT]
MID: 06ab121d3c0f4d8c94652323b8f735c6
UID: SDOC-SSS-70
STATUS: Active
TITLE: Move nodes between documents
STATEMENT: >>>
The Requirements Tool shall allow moving nodes (sections, requirements) between documents.
<<<

Advantages of using machine identifiers:

  1. Machine identifiers provide a robust means of identifying documents, sections, requirements, or custom nodes. An MID can uniquely identify a given node, independent of other fields like UID or TITLE.

  2. The unique identification of nodes via MIDs enhances the effectiveness of StrictDoc’s Diff/Changelog functionality. It allows the algorithm to accurately match requirements, sections, or document nodes, even if they are moved, renamed, or undergo metadata changes.

  3. MIDs increase the portability of requirements data. Even when UID naming conventions change or nodes are relocated, the MID continues to uniquely identify the original node.

For larger projects, particularly those with extended maintenance cycles, we strongly recommend activating machine identifiers early in the project lifecycle. This proactive approach ensures robust tracking and management of documentation throughout the project’s duration.

Custom grammars

Observation: Different industries have their own types of requirements documents with specialized meta information. Examples: ASIL in the automotive industry or HERITAGE field in some of the requirements documents by NASA.

StrictDoc allows declaration of custom grammars with custom fields that are specific to a particular document.

First, such fields have to be registered on a document level using the [GRAMMAR] field. The following example demonstrates a declaration of a grammar with four fields including a custom VERIFICATION field.

[DOCUMENT]
TITLE: How to declare a custom grammar

[GRAMMAR]
ELEMENTS:
- TAG: REQUIREMENT
  FIELDS:
  - TITLE: UID
    TYPE: String
    REQUIRED: True
  - TITLE: VERIFICATION
    TYPE: String
    REQUIRED: True
  - TITLE: TITLE
    TYPE: String
    REQUIRED: True
  - TITLE: STATEMENT
    TYPE: String
    REQUIRED: True
  - TITLE: COMMENT
    TYPE: String
    REQUIRED: True

This declaration configures the parser to recognize the declared fields as defined by a user. Declaring a special field as REQUIRED: True makes this field mandatory for each and every requirement in the document.

When the fields are registered on the document level, it becomes possible to declare them as the [REQUIREMENT] special fields:

[REQUIREMENT]
UID: ABC-123
VERIFICATION: Test
STATEMENT: System A shall do B.
COMMENT: Test comment.

Note: The order of fields must match the order of their declaration in the grammar.

Supported field types

The supported field types are:

SDoc grammar field types

Field Type

Description

String

Simple String

SingleChoice

Enum-like behavior, one choice is possible

MultipleChoice

comma-separated words with fixed options

Tag

comma-separated list of tags/key words. Only Alphanumeric tags (a-z, A-Z, 0-9 and underscore) are supported.

Reference

DEPRECATED: comma-separated list with allowed reference types: ParentReqReference, FileReference. In the newer versions of StrictDoc (0.0.45+), a separate RELATIONS: section is used to configure the available relations.

Example:

[DOCUMENT]
TITLE: How to declare a custom grammar

[GRAMMAR]
ELEMENTS:
- TAG: REQUIREMENT
  FIELDS:
  - TITLE: UID
    TYPE: String
    REQUIRED: True
  - TITLE: ASIL
    TYPE: SingleChoice(A, B, C, D)
    REQUIRED: True
  - TITLE: VERIFICATION
    TYPE: MultipleChoice(Review, Analysis, Inspection, Test)
    REQUIRED: True
  - TITLE: UNIT
    TYPE: Tag
    REQUIRED: True
  - TITLE: TITLE
    TYPE: String
    REQUIRED: True
  - TITLE: STATEMENT
    TYPE: String
    REQUIRED: True
  - TITLE: COMMENT
    TYPE: String
    REQUIRED: True
    REQUIRED: True
  RELATIONS:
  - Type: Parent
  - Type: File

[FREETEXT]
This document is an example of a simple SDoc custom grammar.
[/FREETEXT]

[REQUIREMENT]
UID: ABC-123
ASIL: A
VERIFICATION: Review, Test
UNIT: OBC, RTU
TITLE: Function B
STATEMENT: System A shall do B.
COMMENT: Test comment.
RELATIONS:
- TYPE: Parent
  VALUE: REQ-001
- TYPE: File
  VALUE: /full/path/file.py
Reserved fields

While it is possible to declare a grammar with completely custom fields, there is a fixed set of reserved fields that StrictDoc uses for the presentation of the table of contents and the document structure:

Reserved fields in SDoc’s grammar

Reserved field

Description

UID

Requirement’s UID.

RELATIONS (previously REFS)

StrictDoc relies on this field to link requirements together and build traceability information.

Note: The REFS field is deprecated and replaced with RELATIONS.

TITLE

Requirement’s title. StrictDoc relies on this field to create document structure and table of contents.

STATEMENT

Requirement’s statement. StrictDoc presents this field as a long text block.

COMMENT

One or more comments to a requirement.

RATIONALE

The rationale for a requirement. Visually presented in the same way as a comment.

Relations

The custom grammar configuration includes the optional RELATION: section which specifies the relations a given document supports.

[DOCUMENT]
TITLE: Test Doc

[GRAMMAR]
ELEMENTS:
- TAG: REQUIREMENT
  FIELDS:
  - TITLE: STATEMENT
    TYPE: String
    REQUIRED: True
  RELATIONS:
  - TYPE: Parent

[REQUIREMENT]
STATEMENT: >>>
This is a statement.
<<<
RELATIONS:
- TYPE: Parent
  VALUE: ID-001

The supported relation types are Parent, Child, File. The Parent/Child relations are valid between requirements, the File relation connects a requirement with a file.

The default grammar relations, when a custom grammar is not specified, are Parent and File.

Relation roles

StrictDoc’s custom grammar support the configuration of relation roles. The Parent and Child relations can be further specialized with roles, such as Refines, Implements, Verifies, etc.

[DOCUMENT]
TITLE: Test Doc

[GRAMMAR]
ELEMENTS:
- TAG: REQUIREMENT
  FIELDS:
  ...
  RELATIONS:
  - TYPE: Parent
    ROLE: Refines

With this grammar, StrictDoc will only allow creating requirements that have Parent relations with the ROLE: Refines specified. Any other relations will trigger validation errors.

Parent vs Child relations

TL;DR If there is no compelling reason to use the Child relations, avoid using them.

Most of the technical requirements documents can be modeled with just a Parent relation type. A typical traceability graph for a requirements project is typically child-to-parent, where the higher-level parent requirements are referred to as “Parents” by their child requirements.

For example, in one (parent) document:

[REQUIREMENT]
UID: PARENT-1
TITLE: Parent requirement
STATEMENT: >>>
...
<<<

Somewhere in another child document:

[REQUIREMENT]
UID: CHILD-1
TITLE: Child requirement
STATEMENT: >>>
...
<<<
RELATIONS:
- TYPE: Parent
  VALUE: PARENT-001

In some very special cases, it may be desired to also use the Child relations. For example, creating a so-called Compliance Matrix between a standard and a project requirement can use the Child relation to connect both the upper-level standard requirement with a project-level technical requirement:

[DOCUMENT]
TITLE: Standard X Compliance Matrix

[GRAMMAR]
ELEMENTS:
...
RELATIONS:
- TYPE: Parent
- TYPE: Child

[REQUIREMENT]
COMPLIANCE: Compliant.
STATEMENT: >>>
This is a compliance statement regarding the Standard X's STANDARD-001 requirement...
<<<
REFS:
- TYPE: Parent
  VALUE: STANDARD-001
- TYPE: Child
  VALUE: PROJECT-001

With such a setup, StrictDoc generates the correct traceability graph that will link together the requirements of the PROJECT with the requirements of the STANDARD through the requirements of the compliance matrix.

Another example can be adapting the requirements of the Off-the-Shelf (OTS) project to the higher-level requirements of the user project. An intermediate requirements document can be created that connects the parent requirements of the user project with the immutable child requirements of the OTS project. This intermediate document can link the user requirement with the Parent and the OTS project with a Child link.

Both examples above involve activity called Tailoring when an intermediate document (Compliance Matrix) serves as an interface between two layers of documents.

Search and filtering

StrictDoc supports the search and filtering of document content.

The web interface includes the Search screen, designed for conducting queries against a document tree. The command-line interface supports filtering of requirements and sections through the export and passthrough commands.

Query engine

The syntax of the search query is inspired by Python, utilizing a fixed grammar that converts search queries into corresponding Python expressions.

Important rules:

  • Every query component shall start with node..

  • and and or expressions must be grouped using round brackets.

  • Only double quotes are accepted for strings.

Query examples

Query

Description

node.is_requirement

Find all requirements.

node.is_section

Find all sections.

node.is_root

Find all requirements or sections from documents with ROOT: True. See Document for the description of the ROOT option.

(node.is_requirement and "System" in node["TITLE"])

Find all requirements with a TITLE that equals to “System”.

(node.is_requirement and node.has_parent_requirements)

Find all requirements which have parent requirements.

(node.is_requirement and node.has_child_requirements)

Find all requirements which have child requirements.

Filtering content

Both export and passthrough command-line interface commands support filtering documentation content with --filter-requirements and --filter-sections options.

Both options are based on the Query Engine, so the same rules that are valid for Search also apply for filtering. When a filter is applied, only the whitelisted requirements/sections will be exported.

Example:

eclair_reqman export . --filter-requirements '"System" in node["TITLE"]'

Markup

The Restructured Text (reST) markup is the default markup supported by StrictDoc. The reST markup can be written inside all StrictDoc’s text blocks, such as [FREETEXT], STATEMENT, COMMENT, RATIONALE.

See the reST syntax documentation for a full reference.

The support of Tex and HTML is planned.

Images

To insert an image into a document, create a folder named _assets alongside your document and then place the image file into it.

This is the example of how images are included using the reST syntax:

[FREETEXT]
.. image:: _assets/sandbox1.svg
   :alt: Sandbox demo
   :class: image
[/FREETEXT]

Note: Currently, it is not possible to upload images via the web user interface. Therefore, you must manually place the image into the _assets folder using either the command-line or a file browser.

Mathjax support

StrictDoc can include the MathJax Javascript library to all of the document templates. To activate MathJax, edit the strictdoc.toml config file in the root of your repository with documentation content.

[project]
title = "My project"

features = [
  "MATHJAX"
]

Example of using Mathjax:

[FREETEXT]
The following fragment will be rendered with MathJax:

.. raw:: latex html
    $$
    \mathbf{\underline{k}}_{\text{a}} =
    \mathbf{\underline{i}}_{\text{a}} \times
    \mathbf{\underline{j}}_{\text{a}}
    $$

[/FREETEXT]

See Selecting features for the description of other features.

Export formats

HTML documentation tree by StrictDoc

This is a default export option supported by StrictDoc.

The following command creates an HTML export:

eclair_reqman export docs/ --formats=html --output-dir output-html

Example: This documentation is exported by StrictDoc to HTML: StrictDoc HTML export.

Note: The options --formats=html and --output-dir output-html can be skipped because HTML export is a default export option and the default output folder is output.

Standalone HTML pages (experimental)

The following command creates a normal HTML export with all pages having their assets embedded into HTML using Data URI / Base64. In the project’s strictdoc.toml file, specify:

[project]

features = [
  "STANDALONE_DOCUMENT_SCREEN"
]

The generated document are self-contained HTML pages that can be shared via email as single files. This option might be especially useful if you work with a single document instead of a documentation tree with multiple documents.

HTML export via Sphinx

The following command creates an RST export:

eclair_reqman export YourDoc.sdoc --formats=rst --output-dir output

The created RST files can be copied to a project created using Sphinx, see Getting Started with Sphinx.

cp -v output/YourDoc.rst docs/sphinx/source/
cd docs/sphinx && make html

StrictDoc’s own Sphinx/HTML documentation is generated this way, see the Invoke task: invoke sphinx.

PDF export via Sphinx/LaTeX

The following command creates an RST export:

eclair_reqman export YourDoc.sdoc --formats=rst --output-dir output

The created RST files can be copied to a project created using Sphinx, see Getting Started with Sphinx.

cp -v output/YourDoc.rst docs/sphinx/source/
cd docs/sphinx && make pdf

StrictDoc’s own Sphinx/PDF documentation is generated this way, see the Invoke task: invoke sphinx.

Manage project tree

Automatic assignment of requirements UID

To assign requirement UIDs automatically:

strictdoc manage auto-uid <path-to-project-tree>

The command goes over all requirements in the project tree and assigns missing UIDs automatically. The project tree is mutated in-place.

By default, the assignment happens based on the requirement mask REQ-, so the requirements will get the UIDs of REQ-001, REQ-002, …

If a document-level or a section-level requirement mask is provided, the UIDs will be generated based on that mask.

A document-level requirement mask:

[DOCUMENT]
TITLE: Hello world doc
REQ_PREFIX: MYDOC-

A section-level requirement mask:

[SECTION]
TITLE: Section 2.
REQ_PREFIX: LEVEL2-REQ-

Traceability between requirements and source code

Note: This feature is experimental, the documentation is incomplete.

StrictDoc allows connecting requirements to source code files. Two types of links are supported:

1) A basic link where a requirement links to a whole file.

[REQUIREMENT]
UID: REQ-001
RELATIONS:
- TYPE: File
  VALUE: file.py
TITLE: File reference
STATEMENT: This requirement references the file.

2) A range-based link where a requirement links to a file and additionally in the file, there is a reverse link that connects a source range back to the requirement:

The requirement declaration contains a reference of the type File:

[REQUIREMENT]
UID: REQ-001
RELATIONS:
- TYPE: File
  VALUE: file.py
TITLE: Whole file reference
STATEMENT: This requirement references the file.py file.
COMMENT: >>>
If the file.py contains a source range that is connected back to this
requirement (REQ-001), the link becomes a link to the source range.
<<<

The source file:

# [REQ-002]
def hello_world():
    print("hello world")
# [/REQ-002]

To activate the traceability to source files, configure the project config with a dedicated feature:

[project]

features = [
  "REQUIREMENT_TO_SOURCE_TRACEABILITY"
]

By default, StrictDoc looks for source files in a directory from which the strictdoc command is run. This can be changed by using the source_root_path project-level option.

See Project-level options for more details about the project-level options.

The strictdoc-examples repository contains executable examples including the example of requirements-to-source-code traceability.

ReqIF support

StrictDoc has an initial support of exporting to and importing from the ReqIF format.

Note: It is not possible to implement a single export/import procedure that works well for all ReqIF XML files produced by various requirements management tools. The export/import workflow is therefore tool-specific. See ReqIF implementation details for more details.

Supported formats:

  • StrictDoc’s “native” export/import between SDoc and ReqIF

Import flow (ReqIF -> SDoc)
eclair_reqman import reqif sdoc input.reqif output.sdoc

The command does the following:

  1. The ReqIF is parsed from XML file to ReqIF in-memory model using the reqif library.

  2. The ReqIF in-memory model is converted to SDoc in-memory model. In this case, sdoc indicates that the native ReqIF-to-SDoc conversion procedure must be used.

  3. The SDoc in-memory model is written to an .sdoc file.

Export flow (SDoc -> ReqIF)
eclair_reqman export --formats=reqif-sdoc %S/input.sdoc

The command does the following:

  1. The SDoc file is parsed to an SDoc in-memory model.

  2. The SDoc in-memory model is converted to a ReqIF in-memory model using the native SDoc-to-ReqIF conversion procedure as indicated by the reqif-sdoc argument.

  3. The ReqIF in-memory model is unparsed a to ReqIF XML file using reqif library.

Excel support

StrictDoc provides a support for Excel XLS on input and Excel XLSX on output.

On input, the headers of sheet1 are used to put together a custom grammar and the requirements are imported one row per requirement. A best effort is made by the importer to recognize names of headers and map these to StrictDoc requirement fields.

Note: A roundtrip “SDoc -> Excel -> SDoc” is not yet supported.

Import flow (Excel XLS -> SDoc)
eclair_reqman import excel basic input.xls output.sdoc

The command does the following:

  1. The Excel XLS is parsed to SDoc in-memory model using the xlrd library.

  2. The SDoc in-memory model is written to an .sdoc file.

Export flow (SDoc -> Excel XLSX)
eclair_reqman export --formats=excel --output-dir=Output input.sdoc

The command does the following:

  1. The SDoc file is parsed to an SDoc in-memory model.

  2. The SDoc in-memory model is converted to an Excel XLSX file using the XlsWriter library

StrictDoc Options

Project-level options

StrictDoc supports reading configuration from a TOML file. The file must be called strictdoc.toml and shall be stored in the same folder which is provided as a path to the SDoc documents.

For example, eclair_reqman export . will make StrictDoc recognize the config file, if it is stored under the current directory.

Project title

This option specifies a project title.

[project]
title = "StrictDoc Documentation"
Path to assets

By default, StrictDoc copies its CSS/JS and other asset files to a folder _static in the HTML output directory.

Sometimes, it is desirable to change the folder name. For example, the GitHub Pages static website engine expects the assets to be found in the assets folder.

The html_assets_strictdoc_dir allows changing the assets folder name:

[project]
html_assets_strictdoc_dir = "assets"
Path to source root

When the REQUIREMENT_TO_SOURCE_TRACEABILITY feature is activated, StrictDoc looks for source files in the directory from which the strictdoc program is run. This can be changed with the source_root_path option.

[project]

features = [
  "REQUIREMENT_TO_SOURCE_TRACEABILITY",
]

source_root_path = "source_root/"

The source_root_path option supports relative paths, e.g. ../source_root/.

Include/exclude document paths

Use include_doc_paths and exclude_doc_paths paths to whitelist/blacklist paths to SDoc documents.

In the following example, StrictDoc will look for all files in the input project directory, except all documents in the tests/ folder.

[project]

include_doc_paths = [
  "**"
]

exclude_doc_paths = [
  "tests/**"
]

The behavior of wildcard symbols * and ** is as follows:

  • The * expands to any combination of symbols that represent a valid file name, excluding the forward and backward slashes, which limits this wildcard to only match a single directory.

  • The ** expands to any combination of valid file name symbols, possibly separated by any number of slashes.

Examples of possible filter strings

Example

Description

docs/* or docs/*.sdoc

Match all documents found in the docs/ folder but not in its subdirectories.

docs/**

Match all documents found in the docs/ folder and all its subdirectories.

**/docs/**

Match all documents found in the docs/ folder and all its subdirectories. The docs/ folder can be a top-level folder or at any level of depth.

Include/exclude source files paths

Use include_source_paths and exclude_source_paths to whitelist/blacklist paths to source files when the traceability between requirements and source files feature is enabled.

[project]

features = [
  "REQUIREMENT_TO_SOURCE_TRACEABILITY"
]

include_source_paths = [
  "src/**"
]

exclude_source_paths = [
  "src/tests/**"
]

The behavior of the wildcards is the same as for the include_doc_paths/exclude_doc_paths options.

Selecting features

StrictDoc has optional features and features that are developed with a lower priority.

The feature of exporting the SDoc documents to HTML document view is a core feature and is always enabled. The option features allows selecting which additional features should be activated or not.

The following is an example of the default configuration. The same features are active/inactive when the option features is not specified.

[project]
title = "StrictDoc Documentation"

features = [
  # Stable features that are enabled by default.
  "TABLE_SCREEN",
  "TRACEABILITY_SCREEN",
  "DEEP_TRACEABILITY_SCREEN",

  # Stable features that are disabled by default.
  # "MATHJAX",

  # Experimental features are disabled by default.
  # "REQIF",
  # "HTML2PDF",
  # "PROJECT_STATISTICS_SCREEN",
  # "STANDALONE_DOCUMENT_SCREEN",
  # "TRACEABILITY_MATRIX_SCREEN",
  # "REQUIREMENT_TO_SOURCE_TRACEABILITY"
]

See Experimental features where the experimental features are outlined.

Enable all features

To select all available features, stable and experimental, specify ALL_FEATURES.

[project]

features = [
  "ALL_FEATURES"
]

The advantage of this option is that all feature toggles become activated, and all extra screens and buttons are generated and visible.

The disadvantage is that StrictDoc spends more time rendering extra screens that might not be needed by a particular user.

If ALL_FEATURES is present, all features are activated, regardless of any other features that are also specified or not.

Disable all features

To disable all features, specify the features option but leave it empty:

[project]

features = [
  # Nothing specified.
]
Server configuration
Host and port

By default, StrictDoc runs the server on 127.0.0.1:5111.

Use the [server] section to configure the host and port as follows.

[project]
title = 'Test project with a host "localhost" and a port 5000'

[server]
host = "localhost"
port = 5000
Command-line interface options
Project title

By default, StrictDoc generates a project tree with a project title “Untitled Project”. To specify the project title use the option --project-title.

eclair_reqman export --project-title "My Project" .
Parallelization

To improve performance for the large document trees (1000+ requirements), StrictDoc parallelizes reading and generation of the documents using process-based parallelization: multiprocessing.Pool and multiprocessing.Queue.

Parallelization improves performance but can also complicate understanding behavior of the code if something goes wrong.

To disable parallelization use the --no-parallelization option:

eclair_reqman export --no-parallelization docs/

Note: Currently, only the generation of HTML documents is parallelized, so this option will only have effect on the HTML export. All other export options are run from the main thread. Reading of the SDoc documents is parallelized for all export options and is disabled with this option as well.

Experimental features

At any point in time, StrictDoc supports features that are still experimental. These features are either not fully developed or their testing has not been completed yet.

A feature is considered stable when all its known edge cases have been covered and enough users report that they have used and tested this feature.

See also Selecting features for general instructions.

Project statistics screen

The project statistics screen displays useful information about a documentation project as well as some requirements-based statistics.

To activate the project statistics screen, add/edit the strictdoc.toml config file in the root of your repository with documentation content.

[project]
title = "My project"

features = [
  "PROJECT_STATISTICS_SCREEN"
]

This feature is not enabled by default because it has not undergone sufficient testing by users. The particular aspect requiring extensive testing is related to StrictDoc’s interaction with Git to retrieve git commit information. There remain certain unexamined edge cases and portability concerns, e.g., testing on Windows, testing projects that have no Git version control, calling StrictDoc outside of a project’s root folder.

HTML2PDF printable document generator

The HTML2PDF screen displays a browser-printable version of a document. Printing from a browser results in a well-formatted PDF document or a well-formatted document printed on paper. The best printing experience is achieved with the Chrome browser which in contrast to Firefox and Safari, preserves the internal hyperlinks in the output PDF.

To activate the HTML2PDF screen, add/edit the strictdoc.toml config file in the root of your repository with documentation content.

[project]
title = "My project"

features = [
  "HTML2PDF"
]

This feature is not enabled by default because the implementation has not been completed yet. The underlying JavaScript library is being improved with respect to our HTML content is split between pages, in particular the splitting of HTML <table> tags is being worked on. One feature that is still missing is the ability to generate user-specific front pages with custom meta information.

Mermaid diagramming and charting tool

The Mermaid tool allows to create diagrams inside of StrictDoc/RST markup as follows:

[FREETEXT]
.. raw:: html

    <pre class="mermaid">
    graph TD
    A[Enter Chart Definition] --> B(Preview)
    B --> C{decide}
    C --> D[Keep]
    C --> E[Edit Definition]
    E --> B
    D --> F[Save Image and Code]
    F --> B
    </pre>
[/FREETEXT]

To activate Mermaid, add/edit the strictdoc.toml config file in the root of your repository with documentation content.

[project]
title = "My project"

features = [
  "MERMAID"
]

This feature is not enabled by default because it has not received enough testing.

Shadow features

At any given moment, StrictDoc may contain one or more features that have been implemented and are supported in the codebase, yet lack documentation.

In most cases, these features are still in their early stages and may not even be documented as experimental features.

The testing of these experimental features is typically done by developers or by selected users who have either requested or expressed interest in a specific feature.

If you happen to stumble upon such a hidden feature, we encourage you to use it and provide bug reports or share your experiences with it. However, please be prepared to encounter various unknown or undefined behaviors in the process.

StrictDoc’s limitations

Limitations of RST support by StrictDoc

StrictDoc uses Docutils for rendering RST to HTML, not Sphinx. The implication is that no Sphinx-specific RST directives are supported. Refer to this issue for the related discussion of the limitations: Unexpected restriction on specific RST directives / compatibility with Breathe Sphinx Plugin #1093.

Limitations of web user interface

The existing implementation of the web user interface is alpha-quality and incomplete. The user interface and the underlying backend implementation are not yet autonomous from the command-line workflow. A user still has to access the command line to run the server and commit the documents to Git manually.

The currently supported workflow for the server command must be hybrid:

  • In one terminal window: run server.

  • In another window: check the changes made by the server in the .sdoc files. Commit the .sdoc files to Git.

Note that currently, StrictDoc server maintains an in-memory state of a documentation tree, and it does not watch over the changes made in the .sdoc files. If you make a change in an .sdoc file manually, you have to restart the server in order for your changes to show up in the web user interface.

The following essential features are still missing and will be worked on in the near future:

  • Editing of documents with non-string grammar fields is not supported yet. Example: The SingleChoice type will not work in the *.sdoc files.

  • Adding images to the multiline fields like requirement’s STATEMENT and section’s FREETEXT.

  • Adding/editing sections with LEVEL: None.

  • Deleting a document.

  • Deleting a section recursively with a correct cleanup of all traceability information.

  • Numerous validation aspects and edge cases of content editing.

  • A separate screen for editing project settings.

  • Editing File-based relations.

Concurrent use of the web user interface

StrictDoc’s web user interface does not handle concurrency. If the same requirement/section is edited by two users at the same time, the last write wins.

The measures for handling concurrent use are planned but have been not implemented yet.

Known issues

This section documents some known issues and non-obvious implementation details.

Exporting document free text to ReqIF and vice versa

ReqIF format does not seem to provide a dedicated convention for a text node to be distinguished from a requirement or a section. StrictDoc implements a workaround: the document’s free text is converted to a section with a ChapterName field that equals “Abstract”. And the other way round: when a ReqIF-to-SDoc converter encounters the first section of a document to be “Abstract”, it is converted to a free text.

Running out of semaphores on macOS

This an edge case on macOS: Python crashes in the Parallelizer class when creating an output queue:

self.output_queue = multiprocessing.Queue()

The fragment of the crash:

sl = self._semlock = _multiprocessing.SemLock(
OSError: [Errno 28] No space left on device

The existing workaround for this problem is to increase a number of semaphores in the macOS config:

sudo sysctl -w kern.posix.sem.max=20000

BUGSENG Extensions

Custom Fields

The following custom fields have been added by BUGSENG to the REQUIREMENT grammar to allow the automatic extraction of configurations from a requirement specification document.

BUGSENG additional fields

Field

Description

COVERAGE_TAG

The doxygen tag to be specified to declare this requirement

COVERAGE_SINGLE

Specifies whether the coverage allows no more than one requirement per entity

The fields specified above shall be added only to a [REQUIREMENT] declaration that defines a requirement coverage. To allow the validation of an .sdoc document that uses these fields, the following custom grammar needs to be added at the top of the document, just below the [DOCUMENT] declaration.

[GRAMMAR]
ELEMENTS:
- TAG: REQUIREMENT
  FIELDS:
  - TITLE: UID
    TYPE: String
    REQUIRED: True
  - TITLE: TITLE
    TYPE: String
    REQUIRED: True
  - TITLE: COVERAGE_TAG
    TYPE: String
    REQUIRED: False
  - TITLE: COVERAGE_SINGLE
    TYPE: SingleChoice(TRUE, FALSE)
    REQUIRED: False
  - TITLE: STATEMENT
    TYPE: String
    REQUIRED: True
  - TITLE: RATIONALE
    TYPE: String
    REQUIRED: False
  - TITLE: COMMENT
    TYPE: String
    REQUIRED: False
  RELATIONS:
  - TYPE: Parent
  - TYPE: Parent
    ROLE: Coverage
Automatic Export of Configurations

An .sdoc file with a suitable structure can be used to automatically export a requirement and coverage specification suitable for including in an ECLAIR configuration. For more information about suitable structures, see ECLAIR Requirements Management.

One or more .sdoc documents can be exported to the corresponding .ecl file like so:

eclair_reqman export --formats ecl [--output-dir dir] Example.sdoc [Example1.sdoc..]

This will produce one .sdoc.ecl file for each input file with a structure similar to the following:

-doc_begin='Automatically extracted from Sorting.sdoc'

-requirement_coverages+={IMPLEMENT, implements, {single}}

-requirement_coverages+={SATISFY, satisfies, {single}}

-requirement_coverages+={TEST-INT, tests/int, {single}}

-requirement_coverages+={TEST-SWO0, tests/swo0, {single}}

-requirement_coverages+={TEST-STRUCT, tests/struct, {single}}

-requirements+={GSF-EXT, {
  GSF-EXT-ASSUM-PREFIX.V0,
  GSF-EXT-ASSUM-MAXLEN.V0,
  GSF-EXT-ASSUM-COMPARE.V0,
  GSF-EXT-ASSUM-EQ.V0,
  GSF-EXT-ASSUM-ELEMSIZE.V0,
  GSF-EXT-ASSUM-COPY.V0
}, {
  TEST-STRUCT,
  TEST-SWO0,
  TEST-INT,
  SATISFY
}}

-requirements+={GSF-SS, {
  GSF-SS-F-SORT.V0,
  GSF-SS-F-PARTITION.V0,
  GSF-SS-F-SWAP.V0
}, {
  TEST-STRUCT,
  TEST-SWO0,
  TEST-INT,
  IMPLEMENT
}}

-doc_end

ECLAIR Requirements Management

When developing software, writing technical specifications is not enough to comply with the prescriptions of many standards. Some of them require some form of traceability (either forward or bidirectional) between requirements and source code. A static analysis platform such as ECLAIR, augmented with the capabilities of StrictDoc has the all the information needed to provide the means to enforce this traceability.

Terminology

ECLAIR defines and uses several standard and non-standard terms for the requirement management. Below are their definitions:

(functional) requirement

A functionality that the software shall present (e.g. a sorting function). Every requirement has a unique identifier.

requirement set

A set of requirements

requirement coverage

One aspect of the requirement that is amenable to checking in the source code (e.g. implementation or testing of a requirement REQ).

coverage target

The definition of a subset of the source code where a set of requirements covering a set of coverages is expected to be found.

coverage tag

The word that marks the presence of a requirement in the documentation. This word is used by ECLAIR to extract the information from a code comment.

code construct

A declaration, statement or macro (selected using a -covering_construct configuration).

Conventions

The following conventions shall be followed when writing requirement specifications for ECLAIR, to allow the extractor to work properly:

  • A requirement must belong to no more that one requirement set. If a requirement is mentioned in multiple requirement sets, it will belong to the last set in the configuration.

    Example:

    -requirements+={SET_A, {X}, {IMPLEMENT}}
    -requirements+={SET_B, {X}, {IMPLEMENT}}
    
    # X belongs only to set SET_B
    
  • One [REQUIREMENT] node for each desired coverage shall be created in the StrictDoc document. This requirement must have a COVERAGE_TAG field and optionally a COVERAGE_SINGLE field set to TRUE.

    Example:

    [REQUIREMENT]
    UID: TEST-INT
    TITLE: Test coverage for integer instance
    COVERAGE_TAG: tests/int
    COVERAGE_SINGLE: TRUE
    STATEMENT: >>>
    All requirements that have a parent-child relation with this
    requirement having ``ROLE: Coverage``
    shall be tested as an instantiation of the system for ``int32_t`` arrays.
    <<<
    
  • For each requirement set, a requirement shall be created. In addition

    • this requirement shall have a relation with ROLE: Coverage for each coverage criteria that shall be applied to this requirement set.

      Example:

    [REQUIREMENT]
    UID: GSF-EXT
    RELATIONS:
    - TYPE: Parent
      VALUE: SATISFY
      ROLE: Coverage
    - TYPE: Parent
      VALUE: TEST-INT
      ROLE: Coverage
    - TYPE: Parent
      VALUE: TEST-SWO0
      ROLE: Coverage
    - TYPE: Parent
      VALUE: TEST-STRUCT
      ROLE: Coverage
    TITLE: External entities requirement set
    STATEMENT: >>>
    The set of all the external entities that are prerequisites to an instantiation
    of the generic sorting function.
    <<<
    
  • For each requirement that has no child requirements, the requirement set it belongs to shall be set as its parent.

    Example:

    [REQUIREMENT]
    UID: GSF-EXT-ASSUM-EQ.V0
    RELATIONS:
    - TYPE: Parent
      VALUE: GSF-GOAL-1.V0
    - TYPE: Parent
      VALUE: GSF-EXT
    TITLE: Array element equality test macro
    STATEMENT: >>>
    ...
    <<<
    

Syntax

Coverages

In the code, requirements must be specified in specially marked comments; each of these comments is associated to the first code construct that follows the comment. ECLAIR extracts from these comments (assuming a doxygen markup is used) the coverage tags and requirements. While it is possible to customize the extraction process, a template is available at "install_dir"/share/config/recipes/REQMAN.ecl. It defines three coverages:

Predefined requirement coverages

Coverage

Tag

Description

IMPLEMENT

@implements or \implements

Implementation coverage

TEST

@tests or \tests

Testing coverage

SATISFY

@satisfies or \satisfies

Prerequisite satisfaction

The tag name has no special meaning to ECLAIR, and it’s possible to extend the replacer to parse other tags, by editing the line

-+replacer={comment_body, "^(?s).*?[@\\\\](tests|implements|satisfies)\\s+(.*?)(\\s[\\\\@].*)?$", "%{reqt($2, @0, $1)}%{comment_body($3, @0)}"}

New coverages can be defined with the following syntax:

-requirement_coverages+={"COVERAGE-ID", "tag", {coverage_flags}}

This creates a coverage COVERAGE-ID, specified by a doxygen tag tag and with a possibly empty set of coverage flags, i.e. constraints that this coverage requires. The only flag available at the moment is single, which specifies whether a coverage tag allows no more than one requirement to be bound to a single code construct.

You can also define derived coverages from coverage tags that are already matched by the replacer; one possible usecase for these is to distinguish between various instantiations of a generic procedure, especially when writing testcases. The derived coverage must be defined with requirement_coverages, such as in:

-requirement_coverages+={"TEST-INT", "tests/int", {}}

and referenced in the code with a / after the requirement it applies to (provided that the requirement belongs to a set whose coverages include TEST-INT).

Example:

/**
 * @tests A/int
*/
void test_A(void) { /* CODE */ }
Part specification

It is also possible to specify that a coverage for a specific requirement shall be traced to several entities (e.g. three functions that together implement a sorting algorithm, for which a single requirement has been defined). This form of information is only present in the code that implements the requirement specification and not in the specification document itself. This is feature is meant to help developers who have to handle coarse-grained requirements that cannot be decomposed further, or to support testing usecases (e.g. testing all the ways a function may fail to work as expected). To support this, an optional part specification can be appended to a requirement identifier in the code comment.

Example:

/**
 * @implements A/int:1/2
*/
void impl_A_1(void) { /* CODE */ }

/**
 * @implements A/int:2/2
*/
void impl_A_2(void) { /* CODE */ }

ECLAIR will check the following properties:

  • For any part specification k/n it shall hold k \le n.

  • If any occurrence of a requirement for a coverage has a part specification, then all other occurrences of that requirement for the same coverage shall have the same total number of parts (i.e. if requirement A has a part specification k/n on some matched construct and j/m on some other matched construct, then n == m).

  • When absent, the implicit part specification is 1/1.

The doxygen comment containing the requirement is then bound to the code construct following it. A few remarks:

  1. While multiple requirements can follow a coverage tag (unless the single flag is set) no duplicate requirement should appear in the comment.

    Example:

    /* OK */
    /**
      * @implements A, B
      *              , C
    */
    void f(void);
    
    /* WRONG */
    /**
      * @implements A, A
    */
    void f(void);
    
  2. No text that is not a requirement can be put between a requirement tag and the next doxygen directive (they start with @ or \).

    Example:

/* OK */
/**
  * @implements A
  * @par Some description
*/
void f(void);

/* WRONG */
/**
* @implements A
* Some description
* @par Some text
*/
void f(void);
  1. It is allowed to have multiple coverages in the same comment, even with the same coverage tag, provided that all other constraints are respected.

    Example:

    /* OK */
    /**
      * @implements A
      * @param x
      * @implements B
    */
    void g(int x) { /* CODE */ }
    
  2. It is allowed to place stacked doxygen comments to document a code construct. The requirements listed in the comments will all be anchored to the following construct (if it’s matched by a -covering_construct configuration).

    Example:

    /**
      * @implements A
    */
    /**
      * @implements B
    */
    void impl_A_B(void);
    
  3. If a code construct is generated via macro expansion the requirement coverage comment must be located where the macro is invoked, rather than inside the macro definition.

Note

The coverage comment will be anchored only to the first matching construct generated by the macro expansion. If you need to document multiple code constructs, it is advised to follow the pattern outlined below.

Example:

/* This is ok */

#define M(X, Y) int##X##_t Y

void
f(void) {
  /* The following is an example of coverage of stmt constructs */

  /**
   * @satisfies INT8_T
   */
  M(8, i8);

  /**
   * @satisfies INT16_T
   */
  M(16, i16);
}
/* This is not ok */

#define M(X, Y) \
/** \
 * @satisfies INT8_T \
 */  \
int##X##_t Y

void
f(void) {
  M(8, i8);
}
-requirements+={INT_T,{INT8_T, INT16_T}, {SATISFY}}
-config=B.REQMAN,coverage_target={"main(^example\\.c$)", "set(INT_T)"}
-config=B.REQMAN,covering_construct={stmt, "macro(^M$)", "set(INT_T)"}

Example

This example shows how the requirement management capabilities of ECLAIR can be applied to B.REQMAN.

A requirement specification document in .sdoc format should be redacted. From this document, it is possible to extract a partial ECLAIR configuration that lists all recognized requirements, requirement sets and requirement coverages by following the instructions in the section Automatic export of ecl configurations. The content of the generated configuration file shall then be extended to configure the service B.REQMAN (either by creating another file with a command -eval_file={FILE}.sdoc.ecl or appending to the same file). Three configurations are needed:

  • coverage_target, that defines which analysis frames should contain the requirements specified by the requirement coverage matcher;

  • covering_construct, that defines which code constructs shall be expected to contain certain requirement sets for certain coverages;

  • requirement_replacer, that defines the replacer to be used to extract the requirements from the doxygen comments;

More details on these configurations are available in the documentation of the service B.REQMAN.

Example:

# defines requirement coverages IMPLEMENT and TEST, as well as the replacer doxygen_comment
-eval_file=""install_dir"/share/config/recipes/REQMAN.ecl"

# define requirement sets SET_A and SET_B and/or additional coverages
-requirements+={SET_A, {A1, A2}, {IMPLEMENT, TEST}}
-requirements+={SET_B, {B1, B2, B3}, {IMPLEMENT, TEST}}

-config=B.REQMAN,coverage_target+={"main(foo\\.c)", "set(SET_A||SET_B)"}

-config=B.REQMAN,covering_construct={decl, "kind(method)", "set(SET_A||SET_B)&&cov(IMPLEMENT||TEST)"}
-config=B.REQMAN,covering_construct+={macro, "^M[0-9]$", "set(SET_B)&&cov(IMPLEMENT||TEST)"}

-config=B.REQMAN,requirement_replacer+=doxygen_comment

-enable=B.REQMAN

Keeping the Project Organization Under Control

It is well known that managing the complexity of large and/or critical software systems requires decomposition. That is, the system should be divided into components that are small enough to be reasoned upon, maintained and tested in isolation before being integrated into the system.

Decomposing a software system into components is only the beginning of the story: if the interactions between components is not kept under strict control, little (if anything) is gained. This is important for several reasons, some of which apply to all kinds of systems: restricting interaction will result into high cohesion and low coupling (that is, little information is crossing boundaries), which, in turn, ensure:

  • easier component verification;

  • easier system integration and verification;

  • easier maintainability (components may be modified without affecting the other components in an undesired or unknown way).

When safety and security enter the picture, these generic software engineering considerations compound with the dangers of unwanted dependency and interference among components. For instance, a critical component, which has been developed following a more rigorous process, cannot depend on a non-critical component developed following a less rigorous process.

In this chapter, we present B.INDEPENDENCE: a configurable ECLAIR service that allows the specification of software components and of the allowed interaction between them. Once that is done, static analysis is used to detect and report all disallowed interactions. This encompasses the application of ensuring the safety integrity of a project. That is, given a project’s source code, and a specification of its safety integrity requirements, B.INDEPENDENCE will report any unsafe references to and relationships between the project’s components.

Introduction

The tool B.INDEPENDENCE, being designed for all manner of projects that have various forms of architectural and safety requirements, provides a number of configuration options that allow a wide range of constraints to be specified on and between a project’s components. The notion of component (here used as a shorthand for software component) depends on several factors, including the linguistic support provided by the programming language for encapsulation and modularization. As far as B.INDEPENDENCE is concerned, a component is a set of selected files, declared entities (such as functions, non-local variables and fields) and defined macros. Additionally, the project’s components can be further partitioned into areas, allowing for the specification of exceptions and special requirements for different elements of these components.

The project organization requirements are expressed in the form of permissions and actions between the referring and referred components where the referring component is that of the nearest (interesting) file, entity or macro that contains the reference.

To better understand the core elements of the tool B.INDEPENDENCE, we provide here three small illustrative examples.

For a complete specification of B.INDEPENDENCE and the configuration options see B.INDEPENDENCE.

Example 1: Safety/Non-Safety Decomposition

In this example, there are safety constraints that restrict calls between functions in different components. The aim is to check that no function call violates a safety constraint.

Project Safety Components

First the project components need to be specified. In this example, there are two components SR (acronym of Safety Related) and NSR (Not Safety Related) containing the functions in the project for which this coarse safety-relatedness specification was provided. As we cannot be sure that SR and NSR constitute a partition of the entire project, we also add a component unknown for all other functions, if any, in the given project. The safety constraint is that SR functions may only call other SR functions: in fact, if function f() is safety-related, hence it must be developed and tested according to safety-adequate standards, and f() calls g(), then also g() must be developed and tested according to such standards. In other words, a reliable function cannot call an unreliable one, for otherwise none of the two would be reliable.

The configuration option all_component_entities, requires an entity matcher — see the global configure option -entity_selector — and the following line indicates to ECLAIR that, for this example, the only interesting entities are functions:

-config=B.INDEPENDENCE,all_component_entities+="kind(function)"

The configuration option component_entities places functions fun1() and fun2() in component SR and fun3() and fun4() in component NSR. All other functions, including main(), are placed in component unknown.

-config=B.INDEPENDENCE,component_entities+=
                {SR, content, "name(fun1)"},
                {SR, content, "name(fun2)"},
                {NSR, content, "name(fun3)"},
                {NSR, content, "name(fun4)"},
                {unknown, content, "any()"}

Note that component_entities has three fields, the first being the component name, the second (content in this example) indicates the required tracking, while the last argument, giving the function’s unqualified name, is an entity matcher — see the global configure option -entity_selector.

Permissions

By default, calls are always allowed between functions in the same component; hence NSR functions can call any NSR functions, SR functions can call any SR functions, and unknown functions can call any unknown functions.

However, we need to specify that calls from NSR functions to SR and unknown functions are allowed:

-config=B.INDEPENDENCE,component_allows+="from(NSR)&&to(SR||unknown)"

and also that unknown functions can call NSR and SR functions:

-config=B.INDEPENDENCE,component_allows+="from(unknown)&&to(SR||NSR)"

All other calls that are not explicitly allowed are reported as violations.

Information Reports

B.INDEPENDENCE also provides a means of checking the contents of a component. For instance, for this example, maybe to help in debugging, we can request information reports that show all the functions that are in the component unknown.

-config=B.INDEPENDENCE,show_component_entities=unknown

Note that the configuration option show_component_entities uses a component matcher to specify what entities should be shown. More generally, the show_component_files, show_component_entities and show_component_macros configuration options use full component matchers to specify what files, entities and macros should be shown.

Example 1, With Exception

Suppose that the configuration given in Example 1 caused the analyzer to produce violation reports concerning compiler intrinsic functions. This may happen because compiler intrinsics have not been inserted in the SR component, and thus have ended up in the unknown component and B.INDEPENDENCE correctly reports calls to them from the SR component as violations of the safety constraints.

To avoid this, the configuration could be amended to include such intrinsics in the SR component. As the global configure option -entity_selector provides the selector intrinsic() that selects all compiler intrinsic functions, it would be sufficient to add to the configuration in Example 1 the line:

-config=B.INDEPENDENCE,+component_entities={SR, content, "intrinsic()"}

This would correspond to the view “we want to treat all intrinsic functions as SR functions”. By leaving the rest of the configuration unchanged, no reports for any calls to intrinsic functions (now a part of SR themselves) would be shown.

Instead, for the purpose of illustrating the power and flexibility of B.INDEPENDENCE, we suppose that we are not completely convinced of treating all the compiler intrinsic functions as SR functions, and that we prefer that calls from SR functions to intrinsic functions are reported as cautions. To achieve this, we place all intrinsic functions in a special area, called intrinsic, of the unknown component.

Observe that an area names a subset of the elements of a component. A full component name has the form ID/AREA where ID is the component base name and AREA the name of an area within the component. This allows a configuration to treat a component’s areas in a way distinct from its other areas. Note that every component has, by default, an area represented by the empty string that consists of all elements in the component, so that the full component name for the complete component with base name ID is “ID/”.

Therefore, in this version of the example, we denote the intrinsic area of the unknown component by unknown/intrinsic and add the line:

-config=B.INDEPENDENCE,+component_entities=
           {"unknown/intrinsic", content, "intrinsic()"}

To specify that calls to intrinsic functions from SR functions are reported as cautions we need to use the relation_report configure option:

-config=B.INDEPENDENCE,+relation_report=
          {"from(SR)&&to(unknown/intrinsic)", caution}

Note that the configuration option component_allows shown previously is a forwarding parameter, that is, it is regarded as sugar for a relation_report parameter with "" for the second field (in this context "" means “do not report”). Hence, the configuration lines

-config=B.INDEPENDENCE,component_allows+="from(NSR)&&to(SR||unknown)"
-config=B.INDEPENDENCE,component_allows+="from(unknown)&&to(SR||NSR)"

are equivalent to

-config=B.INDEPENDENCE,relation_report+={"from(NSR)&&to(SR||unknown)", ""}
-config=B.INDEPENDENCE,relation_report+={"from(unknown)&&to(SR||NSR)", ""}

Example 2: ASIL Decomposition

Consider an automotive project where the different program entities are assigned a safety integrity level in the set { QM, ASIL_A, ASIL_B, ASIL_C, ASIL_D }. This set is assumed to be totally ordered: QM means not safety-critical, ASIL_D means maximum criticality. For simplicity, we assume the assignment of the safety integrity levels (i.e., QM, ASIL_A, ASIL_B, ASIL_C, ASIL_D) is file based, so we have that each safety integrity level corresponds to a distinct set of files. The constraint to be enforced is that no entity with a higher safety integrity level depends on an entity with a lower safety integrity level.

Project Safety Components

The configuration option component_files places the files and their contents in their components:

-config=B.INDEPENDENCE,component_files+=
                {ASIL_A, "^asila_src[1-9]\\.c$"},
                {ASIL_A, "^asila_hdr[1-9]\\.h$"},
                {ASIL_B, "^asilb_src[1-9]\\.c$"},
                {ASIL_B, "^asilb_hdr[1-9]\\.h$"},
                {ASIL_C, "^asilc_src[1-9]\\.c$"},
                {ASIL_C, "^asilc_hdr[1-9]\\.h$"},
                {ASIL_D, "^asild_src[1-9]\\.c$"},
                {ASIL_D, "^asild_hdr[1-9]\\.h$"},
                {QM, "any()"}

Note that all files not explicitly placed in the components ASIL_A, ASIL_B, ASIL_C or ASIL_D are placed in component QM.

The following configuration, using option all_component_entities, indicates to ECLAIR that only variables and functions with (external or internal) linkage are interesting:

-config=B.INDEPENDENCE,all_component_entities+=
                "linkage(has_linkage)&&kind(var||function)"

Using option component_entities, the following configuration defines the components of all interesting entities:

-config=B.INDEPENDENCE,component_entities+=
                {ASIL_A, content,
                 "any_decl(loc(top(file(^asila_hdr[1-9]\\.h$))))"},
                {ASIL_B, content,
                 "any_decl(loc(top(file(^asilb_hdr[1-9]\\.h$))))"},
                {ASIL_C, content,
                 "any_decl(loc(top(file(^asilc_hdr[1-9]\\.h$))))"},
                {ASIL_D, content,
                 "any_decl(loc(top(file(^asild_hdr[1-9]\\.h$))))"},
                {QM, content, "any()"}

The following configuration, using option all_component_macros, indicates to ECLAIR that only macros defined in the user headers or the main file are interesting (so that all system macros are ignored):

-config=B.INDEPENDENCE,all_component_macros+=
                "loc(top(file(kind(user||main_file))))"

By setting the first field to "", the following configuration, using option component_macros, specifies that all interesting macros are in the default component for the file where they are declared or defined:

-config=B.INDEPENDENCE,component_macros+={"", macro_file, "any()"}

Note that, similarly to component_entities, the option component_macros has three fields, the first being the component name, the second (macro_file in this example) indicates the required tracking, while the last argument, "any()", matches any macro — see the global configure option -macro_selector.

These configurations work because we are assuming that a strict discipline has been exercised in defining the source files’ contents. Let us consider the case where this is almost, but not completely, true: a variable called crit is declared in a file that is assigned to component QM but we want it in component ASIL_A. This effect would be achieved by putting the following configuration after the ones listed above:

-config=B.INDEPENDENCE,+component_entities={ASIL_A, content, "name(crit)"}

The same effect could have been achieved by putting the following configuration before the ones listed above:

-config=B.INDEPENDENCE,component_entities+={ASIL_A, content, "name(crit)"}

Note the different position of the + sign: the component_entities option, as well as the options component_files, component_macros, component_tag, component_relations, component_allows and relation_report, is a short circuit tagger.

Domains and Tags

In order to facilitate the specification of the relationship among components, the components can be assigned to domains with an associated tag using the configure option component_tag. For instance, if we associate to components a domain constituted by numerical tags, we can reflect numerical relationships between components.

-config=B.INDEPENDENCE,component_tag+=
                {QM, levels, 0},
                {ASIL_A, levels, 1},
                {ASIL_B, levels, 2},
                {ASIL_C, levels, 3},
                {ASIL_D, levels, 4}

In this example, we just define one domain, called “levels” that contains the five numeric values 0, 1, 2, 3, 4 corresponding to the five safety integrity levels. The first field of the configuration option component_tag is a tag component matcher which, as illustrated above, can be the component base name itself.

Permissions

As explained in Example 1, by default all actions between files, entities and macros in the same component are allowed.

So we only need to specify the constraint regarding the safety levels of the components (and represented by the components’ domains and tags):

-config=B.INDEPENDENCE,component_allows+=
         "tag(levels < levels)&&action(include||expand||read||write||call)"

The value of this option is a permission matcher with two built-in selectors:

  • The constraint tag(levels < levels):

    this has two instances of the same domain, levels; the left-hand instance is for the referring component while the right-hand instance is for the referred component. The values compared using the relational operator < are the tags that are associated to the domains for the matching components.

  • The constraint action(include||expand||read||write||call) indicates that only the specified actions are allowed.

Note that by using the tag(DOM1 OP DOM2) constraint we can specify very succinctly the many allowed dependencies between the components. In particular, in this example, tag(levels < levels) specifies that the component QM can depend on ASIL_A, …, ASIL_D; ASIL_A can depend on ASIL_B, …, ASIL_D; and so on. Hence, since, for example, QM has the levels tag 0 while ASIL_D has the levels tag 4, any file in the QM component may include a file in the ASIL_D component, and similarly interesting entities and macros in QM may expand, read, write or call the interesting entities and macros in ASIL_D.

Observe that a component can be associated with more than one domain and the tags are qualified by the domain in which they are set. For example, we could have domains color and size, where the first domain would include colors such as red, yellow and green while the domain size would have numeric values. If we wrote color =< color, then the colors would be compared lexicographically, whereas if we had the constraint size =< size, the numerical values would be compared.

Any action between the files, entities or macros, not allowed by default or not explicitly stated, is reported as a violation.

Example 3: Layering

This is an example of network software that is meant to obey the Open Systems Interconnection (OSI) layer architecture. An application software program needs to use the services of a network stack. The application component identified by APPLICATION is constituted by files a.h, b.h, a.c and b.c. The network stack has three components corresponding to OSI layers, identified by DATA_LINK, NETWORK and TRANSPORT, and constituted by files data_link_1.h, data_link_1.c, data_link_2.h, data_link_2.c, and so on. We want to make sure the network layers are not bypassed. For example, if the DATA_LINK component is accessed bypassing the NETWORK component, then a packet that cannot be routed may be built, and such packet will probably be discarded by the network.

Project Components

The main source files for each translation unit and the included user header files are placed in components depending on their base name:

-config=B.INDEPENDENCE,component_files+=
                {APPLICATION, "^[ab]\\.[ch]$"},
                {TRANSPORT, "^transport_[0-9]+\\.[ch]$"},
                {NETWORK, "^network_[0-9]+\\.[ch]$"},
                {DATA_LINK, "^data_link_[0-9]+\\.[ch]$"},
                {"", "kind(main_file||user)"}

The safety requirements for this project concern the functions and variables that have linkage:

-config=B.INDEPENDENCE,all_component_entities+=
      "kind(function||var)&&linkage(has_linkage)"

The interesting entities are placed in the same components as the files where they are declared or, when that file is not in a named component, in the component APPLICATION:

-config=B.INDEPENDENCE,component_entities+=
                {DATA_LINK, content,
                 "any_decl(loc(top(file(^data_link_[0-9]+\\.h$))))"},
                {NETWORK, content,
                 "any_decl(loc(top(file(^network_[0-9]+\\.h$))))"},
                {TRANSPORT, content,
                 "any_decl(loc(top(file(^transport_[0-9]+\\.h$))))"},
                {APPLICATION, content, "any()"}

Component Relations

The constraint to be enforced is that a component may be only referred to by a component in the layer directly above it. That is:

  • only the APPLICATION component may refer to TRANSPORT;

  • only the TRANSPORT component may refer to NETWORK;

  • only the NETWORK component may refer to DATA_LINK, with just one exception: that the APPLICATION component may refer to the link_status() function in DATA_LINK.

To support these constraints, we define a corresponding over relation between the components:

-config=B.INDEPENDENCE,component_relation+=
         {APPLICATION, over, "TRANSPORT"},
         {TRANSPORT, over, "NETWORK"},
         {NETWORK, over, "DATA_LINK"}

Permissions

Lastly the allowed relations between the components are specified using the configure option component_allows:

-config=B.INDEPENDENCE,component_allows+=
         "rel(over)&&action(include||read||call)"

To support the exception, we define a new area called “except” in the component DATA_LINK to include the link_status() function:

-config=B.INDEPENDENCE,+component_entities=
         {"DATA_LINK/except", content, "^link_status\\(.*$"}

Finally, we specify the allowed additional relation for the exception between the from and to components using a full component matcher:

-config=B.INDEPENDENCE,component_allows+=
         "from(^APPLICATION/.*$)&&to(DATA_LINK/except)&&action(call)"

Note that the from and to constraints need to use a full component matcher and the constraints from(^APPLICATION/.*$) and to(DATA_LINK/except) illustrates that when this matcher uses a regular expression to match the components, it matches the full component name and not just the base name.

Tracking and Actions

The constraints on the interaction among project components are expressed in the form of permissions and actions between the referring and referred components. Although the referred component is clearly defined by the file, entity or macro being referenced, the referring component can depend on several factors. We consider each of the component elements: files, entities and macros, separately.

Files:

The only allowed action is include; in this case the referred component is the component of the included file and the referrer is the component of the including file.

Entities:

The only allowed actions are the access actions read, write and call; the referred component is that of the declaration for the referenced variable or function and the referrer is that of the nearest interesting containing entity or file. The tracking specified by the configuration option component_entities for the referred component can take one of three values:

  • content: the referred entity is a variable or function; if the access is call, the entity must be a function and the function calls are tracked, otherwise the content of the variable must be read or written, depending on the allowed access;

  • field: the referred entity is a field and the content of the field must be read or written, depending on the allowed access;

  • address: the referred entity is a variable with pointer type and the content of the pointee must be read or written, depending on the allowed access.

Macros:

The only allowed action is expand and the referred component is that of the expanded macro. The referrer will depend on the tracking specified by the configuration option component_macros for the referred component:

  • macro_file: if the expansion is in a macro body, the referrer is the component of the macro definition, otherwise it is the containing file;

  • macro_entity: if the expansion is in a macro body, the referrer is the component of the macro definition, otherwise it is the containing entity or file;

  • entity: the referrer is the component of the entity that has the top expansion;

  • address: in this case, the expansion must be to a possibly wrapped integer literal address and the referrer is the component of the nearest interesting containing entity.

Component Matchers

The configuration options component_tag, component_relation, show_component_files, show_component_entities and show_component_macros require a component matcher in one of their fields. Furthermore, the permission matcher also has several selectors with a component matcher as an argument.

There are three variants of a component matcher; which variant should be used depends on the configuration option requiring them:

  • component_tag: this uses the tag variant, matching a component solely using the component base name — see Domains and Tags in Example 2;

  • component_relation: this uses the relation variant that extends the tag variant by allowing a component to be matched by its domain and tag — see Component Relations; Example 3;

  • show_component_files, show_component_entities and show_component_macros: this full variant allows the selection of a component by its full name, by its domain and tag and also from the defined relations between the component and another component.

See B.INDEPENDENCE for a full specification of each of these variants.

Permission Matchers

The configuration option component_allows requires a permission matcher to specify the constraints allowed between the components. Similarly, the configuration option relation_report requires a permission matcher to specify if a component should be reported and, if so, what kind of report should be shown.

The built-in selectors for this matcher can constrain the from and to components using component matchers, the allowed actions — see Tracking and Actions —, the allowed relations defined by component_relation and the allowed equality and relational operations between the tags defined by component_tag.

Subsections Permissions of Example 1, Permissions of Example 2 and Permissions of Example 3 provide illustrations of the use of the configuration options component_allows and relation_report with their permission matchers.

See B.INDEPENDENCE for a full specification.

ECLAIR Code Scout

An important issue that often occurs in safety-critical software development when reusing existing software is the need to assess and document which portions of such existing software are actually used by the system. Another scenario where it is important to be able to pinpoint what software is potentially used happens when the scope of the qualification effort for a library is required and such qualification is demanded by functional safety standards.

ECLAIR Code Scout, implemented with the ECLAIR service B.SCOUT is a component of the ECLAIR Software Verification Platform that allows developers to easily and automatically derive the potentially used callable entities (functions, methods, etc.) used by a certain configuration of a software project by simply analyzing the build.

In this chapter, we will present the basic functionality of B.SCOUT, some advanced use cases and a few examples with explanations of the output, illustrating how the generated output can provide a deeper understanding of the software being developed.

Introduction

The tool B.SCOUT is a configurable service that allows determining which part of a library or multiple libraries are being used by a project. It does so by reporting all the potentially reachable callable entities in a program. Its input is a set of entry points to the program; the default configuration has the single entry point: the main() function. Additional entry points can be specified via the -extra_references global configuration. From these entry points all potentially reachable edges due to function calls, function pointers and similar callable expressions are explored, leading to the creation of a call graph that is split into multiple reports for each reachable entity.

The basic use of B.SCOUT requires no configuration: in this way, all reachable entities, including those inside the implementation of the standard library of the language being used will be shown. This is sometimes excessive, and the way to limit which parts of the used libraries are considered is via option ignored_edges, which defines conditions on edges between callable entities that should be ignored, thereby limiting the seach scope to e.g. the standard library interface, to exclude the internals of such library.

For a complete specification of B.SCOUT and the configuration options that are available see B.SCOUT.

Note

In order to produce any report, the program under analysis must be linked and the analysis settings must not ignore analysis frames of kind PROGRAM.

Advanced Use

An advanced use-case for B.SCOUT is the generation of .ecl configuration files listing all the potentially reachable entities that have been found; these files can then be used to limit the scope of subsequent analyses with respect to other coding standards applied in a further step to only the portion of code that actually ends up being used in the configuration, therefore automatically excluding any portion of code that may not follow the coding guidelines, but it not of interest in the current analysis.

This is accomplished via the configuration options output_entity_selector and output_ecl; the former option specifies an identifier to the -entity_selector that will be produced after the analysis with B.SCOUT, while the other specifies the path to the file where such configuration will be written. If the file is not present, it will be created, and truncated otherwise.

Example

The following example is instructive in showing the functionality of the tool in dealing with function pointers, potentially reachable calls and non-reachable calls (e.g., f() is never reached)

typedef int (*fp)(void);

void f(void) { }
int h(void) { return 1; }

int foo(void) {
  return h();
}

int hof(int (*fn)(void)) {
  return fn();
}

int main(int argc, char **argv) {
  fp funp = foo;
  if ( argc > 1 ) {
    return 0;
  }
  return hof(funp);
}
eclair_env -enable=B.SCOUT,B.REPORT.ECB -- gcc scout_example.c
eclair_report -create_db=PROJECT.ecd /tmp/FRAMES.ecb -load
eclair_report -db=PROJECT.ecd -full_txt=txt
cat txt/by_service_and_first_file/B.SCOUT.etr

Executing the commands above on the example code gives the follwing output:

service B.SCOUT: All callable entities that are possibly reachable from program entry points are shown
  information: 4

  service B.SCOUT --> first file scout_example.c
    information: 4

information for tool B.SCOUT: All callable entities that are possibly reachable from program entry points are shown. (untagged)
scout_example.c:4.5-4.5: Loc #1 [culprit: for program `a.out', function `h(void)' is possibly reachable]
scout_example.c:7.10-7.12: Loc #2 [evidence: function call in function `foo(void)' invokes function `h(void)']

information for tool B.SCOUT: All callable entities that are possibly reachable from program entry points are shown. (untagged)
scout_example.c:6.5-6.7: Loc #1 [culprit: for program `a.out', function `foo(void)' is possibly reachable]
scout_example.c:15.13-15.15: Loc #2 [evidence: `int()' is the canonical type of reference to function `foo(void)' whose address is taken]
scout_example.c:11.10-11.13: Loc #3 [evidence: function `hof(int(*)(void))' makes indirect function call with canonical type `int()']

information for tool B.SCOUT: All callable entities that are possibly reachable from program entry points are shown. (untagged)
scout_example.c:10.5-10.7: Loc #1 [culprit: for program `a.out', function `hof(int(*)(void))' is possibly reachable]
scout_example.c:19.10-19.18: Loc #2 [evidence: function call in function `main(int, char**)' possibly invokes function `hof(int(*)(void))']

information for tool B.SCOUT: All callable entities that are possibly reachable from program entry points are shown. (untagged)
scout_example.c:14.5-14.8: Loc #1 [culprit: for program `a.out', function `main(int, char**)' is reachable]
scout_example.c:14.5-14.8: Loc #2 [evidence: function `main(int, char**)' is externally referenced]


End of report.
  • Starting from the bottom, we can see from the report text that the main() function is found to be an entry point, and thus definitely reachable.

  • The function hof() may or may not be reached depending on the value of argc, thus all function calls that are after this point in the call tree are only possibly reachable.

  • The function foo() is found to be reachable because it could be, and in fact it is, called via the function pointer fn inside hof(), which in turn means that also h() is reachable because it is called by foo().

  • Finally, f() is not found to be reachable because: (a) there is no direct invocation in any of the reachable functions to f(); (b) its type is not compatible with that of the parameter of hof(), thus it cannot be called from that branch.

Automatic Test Data Generation

ECLAIR provides the tool B.TGEN that, given some source code, can automatically synthesize sets of unit test inputs that reach a specified coverage criterion. If instead such coverage cannot be reached due to unfeasible conditions in the program, this will be shown by B.TGEN.

Configuration

In this section we describe the configuration options that influence the behavior of B.TGEN.

Coverage Criteria

Parameters in this section allow the specification of the coverage criteria to be used for testcase generation. Code coverage criteria specify which program entities, such as statements, branches and decisions, should be exercised. Operator coverage criteria specify cases (usually associated to some anomalous behavior) associated to specific semantic operators; for instance, the generation of testcases resulting into an integer divide by zero can be requested.

  • code coverage: Specifies the code coverage criterion for testcase generation.

  • operator coverage short circuit tagger: Specifies the operator coverage criterion for testcase generation.

  • operator special case named sets: Specifies named operator special case sets to be used in the definition of the operator coverage criterion.

  • Prove #ECLAIR_prove conditions: Specifies whether proof of the #ECLAIR_prove conditions should be attempted (by attempting coverage of their negations).

Unfolding and Unrolling

Parameters in this section provide ways to control the unfolding of function calls and unrolling of program loops.

Note:

These parameters reflect some limitations in the current implementation of the tool and should be considered as experimental.

  • max loop iterations: Maximum number of loop iterations to be followed.

Program Semantics

Parameters in this section allow a very fine-grain control of the semantics of the program. The semantics of each semantic operator can be selected from a number of alternatives; for instance, signed integer division can be truncated (as mandated by C99) or floored (as allowed by C89). The semantics of accesses to undefined variables can also be selected as well as all the aspects involved in the use of floating-point quantities.

  • operator semantics: Specifies the operator semantics using an unordered list of groups, each of which has three components:

    • operators: a set of operators,

    • case: a case in the definition of the semantics of an operator,

    • behavior: behavior in the definition of the semantics of an operator.

  • uninitialized variable semantics: Specifies the semantics to be applied to uninitialized variables.

  • default rounding mode: Specifies the default rounding mode for floating-point operations.

  • NaNs allowed: Specifies whether NaNs are allowed in floating-point quantities.

  • -inf allowed: Specifies whether -inf is allowed in floating-point quantities.

  • +inf allowed: Specifies whether +inf is allowed in floating-point quantities.

Limits to Constraint Resolution

Parameters in this section allow controlling the constraint resolution process in order to limit the amount of resources it is allowed to consume.

  • labeling limit: An integer encoding a limit to be applied to the labeling phase of constraint resolution: the higher the value the higher the running time, the lower the chances of getting a don’t know.

  • propagation limit: An integer encoding a limit to be applied to the propagation phase of constraint resolution: the higher the value the higher the running time, the lower the chances of getting a don’t know.

  • DLR limit An integer encoding a limit to be applied to the dynamic linear relaxation phase of constraint resolution: the higher the value the higher the running time, the lower the chances of getting a don’t know.

Debugging and Self-Testing

Parameters in this section are related to debugging and self-testing of the testcase generator. They are only relevant to developers and to those who want to assess the capabilities of the tool.

  • tracing behavior: Specifies the tracing behavior of the service.

  • self-test program filename: An output file where the self-test program is written

Keeping the Project Vocabulary Under Control

The vocabulary used to compose the programs in a software project should be precisely defined in a way that is amenable to automatic checking. In this chapter we explain the services offered by ECLAIR that facilitate this task.

Defining the Project Vocabularies

In ECLAIR, the project vocabulary can be defined by means of several optional components and by a customizable identifier segmentation algorithm.

Identifier Segmentation

Identifier segmentation is the process whereby program identifiers are split into their constituents, each of which hopefully corresponds to a morpheme the programmer had in mind. Segmentation is especially useful in case underscores or CamelCase are not systematically used. For example, astride could be segmented as astride itself, “ast ride”, “a stride” or “astr ide”. The discrimination among such alternatives is performed with the help of dictionaries, collections of words listed along with their frequencies. For instance, in a context where “AST” is often used as an acronym for Abstract Syntax Tree, the “ast ride” segmentation can take place; similarly, the segmentation “astr ide” is made possible by a dictionary reflecting the use of “IDE” for Integrated Development Environment; the decision among these and other alternatives depends on the frequencies of the morphemes involved, as reported by the employed dictionaries.

The segmentation process used by ECLAIR begins with an optional splitting phase based on regular expressions. A list of splitter regular expressions can be provided that possibly contain marked subexpressions. If an identifier matches at least one of the regular expressions in this list, the segmentation process begins by splitting the identifier according to the marked subexpressions in the first matched regular expression. Suppose, for example, that the project rules prescribes that all the global variables have names beginning with g: then, using the splitter regular expression "g([A-Za-z0-9_]*) will contribute to the fact that the right thing happens for identifiers like gMaxLevel, gmaxdecay or gMINDOUBLE.

Segmentation proceeds with several further optional steps, which are performed one after the other. They are:

none

no further segmentation is performed;

non_alpha

strings are split into maximal substrings whose name is only composed of alphabetic characters, throwing away all the non-alphabetic characters;

lower_to_upper

strings are split on every lowercase to uppercase transition;

camel_case

strings are split either in a CamelCase fashion (e.g., “AST Ride”) or by separating the uppercase prefix from the lowercase suffix (e.g., “ASTR ide”); the split is guided by the word frequencies contained in the used dictionaries;

no_case

strings are split using a heuristics based on word frequencies and independently of any case consideration. As this process is quite expensive, option max_no_case_length is used to specify the maximal length of the strings considered for segmentation.

The Project Vocabulary Components

The definition of the allowed vocabulary is constituted by the following components, all of which are optional:

  • a project dictionary: this contains a list of words, all in lowercase, used in the project along with their frequencies; this dictionary can be easily built by service B.COLLDICT;

  • a context dictionary: this contains a list of words, all in lowercase, along with their frequencies, used in a set of projects that constitute the “context” of the project being checked; the purpose of this dictionary is not to provide a list of allowed words, but only to assist the identifier segmentation process, which is especially useful in case underscores or CamelCase are not systematically used; for example, the context dictionary (along with the lists of good and bad words introduced below) helps to determine whether “ASTRIDE” should be segmented as, e.g., astride, “ast ride”, “a stride” or “astr ide”; this dictionary is most conveniently built using service B.COLLDICT;

  • a list of good words: this is a list of extra words, all in lowercase, that can be used in the project; note that the project and context dictionaries are not normally updated on a day-by-day basis; between updates, the list of good words is useful to temporarily contain words that are allowed to be used in the project while still not being present in the project dictionary; note that the list of good words is also used as input to the identifier segmentation process;

  • a list of bad words: this is a list of words, all in lowercase, that should never be used in the project; note that, differently from the list of good words, where words can be dropped once their use in the project has become widespread and the project dictionary has been updated, the list of bad words is meant to increase monotonically, unless the project management decides to allow a formerly non-compliant word; note that the list of bad words is also used as input to the identifier segmentation process;

  • a list of good lexical items that are maximal and match [a-zA-Z0-9_\'-]+; example of such items in double quotes are: “Stehle’-Zimmermann”, “weeks’” and “Knuth2009-c”; note that, differently from words, multiple items cannot be used to compose identifiers;

  • a list of bad lexical items;

  • a list of regular expressions for good lexical items; this is useful to specify things like “all identifiers starting with a lowercase letter with an optional tail represented by a decimal number in the range 1-20 are allowed;”

  • a list of regular expressions for bad lexical items; this is useful to specify things like “no identifier should contain a sequence of two or more underscores;”

  • a list of “splitter regular expressions”; these are regular expressions possibly containing marked subexpressions; if an identifier matches at least one of the regular expressions in this list, the segmentation process begins by splitting the identifier according to the marked subexpressions in the first matched regular expression; suppose, for example, that the project rules prescribes that all the global variables have names beginning with glb: then, using "glb([A-Za-z0-9_]*) will contribute to the fact that the right thing happens for identifiers like glbMaxLevel, glbmaxdecay or glbMINDOUBLE.

The algorithm to decide whether a lexical item LI is reported is the following:

  • if the lowercase form of LI is in the bad items file, then it is flagged;

  • otherwise, if the lowercase form of LI is in the good items file, then it is not flagged;

  • otherwise, if LI matches a bad item regular expression, then it is flagged;

  • otherwise, if LI matches a good item regular expression, then it is not flagged;

  • otherwise LI is segmented according to the list of splitter regular expressions: the first match, if any, determines the initial segmentation, that is further refined by the step below; if there are no matches, segmentation proceeds with the following steps;

  • LI or its substrings obtained with the splitter regexs is/are segmented (further) by first breaking words at any non-alphabetic characters, then exploiting case changes (to properly deal with CamelCase), then breaking same-case words as necessary; the last two steps use the project and the context dictionaries as well as the lists of good and bad words in order to rank the likeliness of the possible splits;

  • then:

    • if any of the words (in lowercase form) resulting from the segmentation is in the bad list, then LI is flagged;

    • otherwise, if all the words (in lowercase form) resulting from the segmentation occur either in the project dictionary or in the list of good words, then LI is not flagged;

    • otherwise, LI is flagged.

Initial Collection of Dictionaries

The task of collecting project and context dictionaries requires some manual work, even though ECLAIR can greatly facilitate the task. The first collection step involves using service B.COLLDICT. A typical invocation of this service is

eclair_env -project_name=PROJECT_ID -project_root=PROJECT_ROOT_DIR \
  -enable=B.COLLDICT \
  -config=B.COLLDICT,project_dictionary, \
  PREFIX/eclair-VERSION/share/dict/en_US \
  -config=B.COLLDICT,segmentation_stops_after,camel_case \
  -config=B.COLLDICT,output_dictionary,/tmp/dict1 -- build_all

This assumes that build_all is a command that will build the entire project (for the initial collection of the project dictionary) or a set of projects (for the context dictionary). It also assumes that environment variables have been set as explained in Chapter Intercepting the Toolchain. In order to improve the segmentation process, a dictionary is required. This might be a problem when an organization is in the process of collecting its own dictionaries for the very first time. In order to help users in this bootstrap process, ECLAIR is shipped with dictionaries such as en_US for U.S. English. Finally, during the initial collection, it makes little sense to push segmentation beyond the camel_case phase.

The above command will write the output dictionary to /tmp/dict1. This, however, cannot directly be used unless the projects built by build_all are known not to contain any unwanted lexical item. Spelling checkers and trusted list of good lexical items can be used to restrict the number of items to be manually checked. For example,

aspell --lang=en_us --ignore-case --list </tmp/dict1 \
  | fgrep -vwif PREFIX/eclair-VERSION/share/dict/cxx >/tmp/words1

uses the aspell spelling checker and a list of words, shipped with ECLAIR in the file cxx, that denote functions, macros, enumeration values, and so forth, that are commonly encountered in C++ programs (PREFIX is the installation prefix of version VERSION of ECLAIR).

The temporary list of possibly bad words /tmp/words1 can be further processed with other spelling checkers, using specialized word lists or even manually in order to remove as many good words as possible. Let us say that we end up with a residual list of possibly bad words in file /tmp/words2. We can now produce a revised list of words with frequencies with

fgrep -vwif /tmp/words2 -e TOTAL_COUNT /tmp/dict1 >/tmp/quasidict2

which can be turned into a dictionary with

echo -e "TOTAL_COUNT\t"$(cut -f2 /tmp/quasidict2 \
  | paste -sd+ | bc) >/tmp/dict2
cat /tmp/quasidict2 >>/tmp/dict2

If the project uses identifiers that are obtained from the mere juxtaposition of different words (a bad idea, by the way), a second run of ECLAIR is necessary to collect a more refined dictionary:

eclair_env -project_name=PROJECT_ID -project_root=PROJECT_ROOT_DIR \
  -enable=B.COLLDICT \
  -config=B.COLLDICT,project_dictionary,/tmp/dict2 \
  -config=B.COLLDICT,context_dictionary, \
  PREFIX/eclair-VERSION/share/dict/en_US \
   -config=B.COLLDICT,segmentation_stops_after,no_case \
   -config=B.COLLDICT,output_dictionary,/tmp/dict3 -- build_all

Note that, this time, we perform full segmentation (with B.COLLDICT parameter segmentation_stops_after set to no_case). Independently of segmentation, during the analysis of /tmp/words1 we may have discovered that the project contains a number of (possibly automatically generated) identifiers that should not be subject to checking or that should be segmented in a peculiar way. In the former case, the second collection can use an option like:

-config=B.COLLDICT,splitter_regexs,{"PFNGL[A-Z0-9]*"}

which will simply ignore all identifiers whose name starts with PFNGL and continues with any sequence of uppercase letters and digits. In the latter case a splitter regular expression with marked subexpressions can be used to obtain the right segmentation as explained above.

Now from dict3 a list of possibly bad words is obtained as explained above; that list is processed using spelling checkers and, from the revised list, a new dictionary is obtained, say /tmp/dict4, is obtained:

aspell --lang=en_us --ignore-case --list </tmp/dict3 \
  | fgrep -vwif PREFIX/eclair-VERSION/share/dict/cxx >/tmp/words3
emacs /tmp/words3  # Erase all words that are OK.
fgrep -vwif /tmp/words3 -e TOTAL_COUNT /tmp/dict3 >/tmp/quasidict4
echo -e "TOTAL_COUNT\t$(cut -f2 /tmp/quasidict4 \
  | paste -sd+ | bc)" >/tmp/dict4
cat /tmp/quasidict4 >>/tmp/dict4

Definition of the Other Vocabulary Components

It is now time to look carefully at each program identifier that the segmentation algorithm cannot divide into words that are in /tmp/dict4. In this example, we will operate under the assumption that the project’s coding standard allows compound identifiers to be built without separating underscores or lowercase-to-uppercase transitions:

eclair_env -project_name=PROJECT_ID -project_root=PROJECT_ROOT_DIR \
  -enable=B.IDNTVCBL \
  -config=B.IDNTVCBL,project_dictionary,/tmp/dict4 \
  -config=B.IDNTVCBL,context_dictionary, \
  PREFIX/eclair-VERSION/share/dict/en_US \
  -config=B.IDNTVCBL,segmentation_stops_after,no_case \
  -enable=B.REPORT.ECB   -config=B.REPORT.ECB,output=/tmp/IDNT_VIOLATIONS_@FRAME@.ecb -- build_all
eclair_report -create_db=/tmp/IDNT_VIOLATIONS.ecd /tmp/IDNT_VIOLATIONS_*.ecb -load

/tmp/IDNT_VIOLATIONS.ecd can be processed with eclair_report as described in Section The eclair_report Command.

Analyzing the reports we will be able to figure out the lists of good words, lexical items and regular expressions that we need to define the project vocabulary.

Lists of bad words, lexical items and regular expressions are, instead, the result of a careful scrutiny of the dictionaries that were used and built during the initial collection phase: for example, we may want to forbid the use of foo even though that word occurs in some English dictionary. Once all the elements have been defined, the project’s identifiers should be checked again with the new options. For instance, if files /tmp/good_items and /tmp/good_words were defined, we should add to the command above the options:

-config=B.IDNTVCBL,good_items_file,/tmp/good_items \
-config=B.IDNTVCBL,good_words_file,/tmp/good_words

Note also that, if the project’s coding standard allows compound identifiers to be built without separating underscores or lowercase-to-uppercase transitions, it will be wise to move most one-letter words out of the dictionaries and list them, instead, in the list of good items. This will prevent unwanted segmentation and acceptance of items that should instead be flagged.

For more information about the use of B.IDNTVCBL see B.IDNTVCBL.

Checking the Vocabulary Used in Comments and Strings

When the vocabulary of identifiers has been captured in a satisfactory way, one can turn attention to comments and analyze the project with a command like the following:

eclair_env -project_name=PROJECT_ID -project_root=PROJECT_ROOT_DIR \
  -enable=B.CMNTVCBL \
  -config=B.CMNTVCBL,project_dictionary,/tmp/dict4 \
  -config=B.CMNTVCBL,context_dictionary, \
  PREFIX/eclair-VERSION/share/dict/en_US \
  -config=B.CMNTVCBL,segmentation_stops_after,no_case \
  -config=B.CMNTVCBL,good_items_file,/tmp/good_items \
  -config=B.CMNTVCBL,good_words_file,/tmp/good_words \
  -enable=B.REPORT.ECB \
  -config=B.REPORT.ECB,output=/tmp/CMNT_VIOLATIONS_@FRAME@.ecb -- build_all

Analysis of the reports will typically reveal:

  • spelling mistakes in comments that have to be fixed;

  • correct lexical items that are currently not recognized as such and should be listed in the file or captured by regular expressions for good lexical items;

  • out-of-date comments that refer to program identifiers that are no longer used.

Once all these issues have been handled we will run the analysis again by taking into account the additional good lexical item we have just identified.

To specify certain comments will not be checked, we can use the configuration parameter comments. For example, to ensure that only the comments beginning with /** are checked, we could add to the above command the option:

-config=B.CMNTVCBL,comments={hide, "!^/**"}

The content of string literals like "hello world" can be also analyzed in a similar way:

eclair_env -project_name=PROJECT_ID -project_root=PROJECT_ROOT_DIR \
  -enable=B.STRNVCBL \
  -config=B.STRNVCBL,project_dictionary,/tmp/dict4 \
  -config=B.STRNVCBL,context_dictionary, \
  PREFIX/eclair-VERSION/share/dict/en_US \
  -config=B.STRNVCBL,segmentation_stops_after,no_case \
  -config=B.STRNVCBL,good_items_file,/tmp/good_items \
  -config=B.STRNVCBL,good_words_file,/tmp/good_words \
  -enable=B.REPORT.ECB \
  -config=B.REPORT.ECB,output=/tmp/STRN_VIOLATIONS_@FRAME@.ecb -- build_all

To ensure only specified strings will be checked, we can use the configuration parameter statements. For example, to check only those string literals that are expanded from macros and whose names begin with MSG, we could add to the above command the option:

-config=B.STRNVCBL,statements={hide, "!call(macro(^MSG.*$)))"}

For more information about the use of B.STRNVCBL and B.CMNTVCBL see B.STRNVCBL and B.CMNTVCBL.

Maintaining the Project Vocabularies

Defining the project vocabularies is not an easy task. The main reason is that the vocabulary is rarely defined a priori. Rather, it has to be defined through a process that is often iterative and needs a good deal of judgement. Life is much easier for those projects that mandate either CamelCase or the use of underscores to separate words in identifiers. In any case, once the project vocabulary components have been defined, their maintenance is relatively straightforward. Even if the process described in Section Initial Collection of Dictionaries has to be repeated from time to time, availability of the old dictionaries and word lists significantly reduces the effort required. Minor maintenance operations include:

  • amending the good/bad item regexs and the splitter regexs in order to accommodate the evolution of the project;

  • amending the good/bad words/items files in order to accommodate changes to the corresponding regexs.

The file containing the list of good words is just a temporary repository: once the project dictionary is recollected, it will be emptied (differently from the file containing the list of good items).

The dictionary also requires maintenance, especially if an incremental approach was chosen whereby questionable words were allowed into the project dictionary not to overwhelm developers with too many reports. In that case, while ambiguous abbreviations, unwanted foreign words and inflections are identified, the dictionary should be cleaned accordingly.

Troubleshooting

This chapter gives indications on the resources that are available to solve issues that may arise while using ECLAIR. It also contains the solution to some common issues that some ECLAIR users might face.

ECLAIR Issues Discovered After the Release

All users with a valid maintenance contract have access to a Known issues project in BUGSENG’s issue-tracking system. All issues that are either internally discovered or have been reported by customers or partners are timely filed under that project:

_images/Known_Issues.png

Known issues are organized under “umbrella issues” each corresponding to a version of ECLAIR. For instance, all ECLAIR 3.11.0 issues are children of the umbrella issue whose summary contains “All ECLAIR 3.11.0 known issues”. Users of a certain version of ECLAIR are strongly invited to monitor the corresponding umbrella issue by clicking on the Monitor button in the lower left corner of the View Issue Details pane: this way, they will get automatic email notification messages whenever any issues under the umbrella are added, resolved, or modified. Needless to say, this recommendation is crucial for all those using ECLAIR for the development of safety-related and/or security-related systems.

The following figure shows the umbrella issue for ECLAIR 3.11.0 and emphasizes the Monitor button to be clicked:

_images/push_the_monitor_button.png

In order to prioritize your analysis of the issues, you can use the filters available in the View Issues tab. A useful filter allows restricting the displayed issues to those pertaining to a certain category. For example, users working on safety- and/or security-related projects may first of all want to see issues in category “Checker false negative”:

_images/issue_selection_by_checker_false_negative_category.png

Issues can also be filtered by tag: for users of certified versions of ECLAIR we have created the tag FSSCF, from Functional Safety and Security Certified Feature. This tag is systematically used to mark issues that may affect ECLAIR features that are certified for use in safety-critical and/or security-critical development. The following figure shows how filtering by this tag is done:

_images/issue_selection_by_FSSCF_tag.png

Protection Issues

ECLAIR is protected with Thales’ Sentinel LDK system. This system is in charge of ensuring that ECLAIR executions are only permitted in presence of a suitable Sentinel key. See the dedicated section in the ECLAIR Frequently Asked Questions: the most up-to-date version of that document is always available in the Guides project in BUGSENG’s issue-tracking system.

Configuration Issues (Not ECLAIR Defects)

This sections contains issues that have to do with unanticipated consequences of the user ECLAIR configuration.

Message WARNING: file FILE as built with command COMMAND is missing SERVICE saved data is shown

This typically happens when a frame is excluded from the analysis using -frames. Analyzing the project frame, ECLAIR does not find any information related to that file.

Windows-Specific Issues (Not ECLAIR Defects)

This sections contains the solution to some Windows-specific issues.

Ctrl-C does not kill eclair_report when used in Cygwin/MSYS mintty window

This is a known problem of mintty/Cygwin.

A solution is to use a CMD window (you can also launch Cygwin’s bash from it).

Message CreateProcessA failed is shown

Likely your antivirus heuristic has wrongly marked libexec/i686/ihook.exe and/or libexec/x86_64/ihook.exe as infected and moved them to a quarantine area.

A solution is to ensure that the file is the same you have received from BUGSENG, exclude it from the antivirus actions, and report the false positive to your antivirus vendor. Note that all ECLAIR executables in the Windows version are digitally signed by BUGSENG with an extended validation (EV) code-signing certificate issued by Sectigo (formerly Comodo), a Microsoft partner enrolled and authorized for Kernel Mode Code Signing as part of the Microsoft Trusted Root Certificate Program.

Message FATAL: the `ECLAIR_EXE' environment variable is undefined is shown

This typically happens under Cygwin. The solution is adding option +trap_open to the options of the eclair_env program. When using the ECLAIR GUI, this can be done by adding +trap_open in the Arguments for eclair_env field of the Settings GUI section.

Linux-Specific Issues (Not ECLAIR Defects)

This sections contains the solution to some Linux-specific issues.

scons-based build is not intercepted

By default scons removes most variables from the environment, including the ones needed by eclair_env to intercept the toolchain components.

To avoid such removal it is enough to add ENV = os.environ to Environment constructor arguments, e.g.:

env = Environment(ENV = os.environ)

Glossary

action

It is the continuous integration and continuous delivery (CI/CD) basic concept in GitHub that allows automating build, test, and deployment pipelines. An action can be triggered by an event on the repository or the platform.

agent

See runner.

analysis file

Any file involved in an ECLAIR analysis. This might be a source code or an object file.

analysis frame

During an analysis, ECLAIR collects information about the built software. This analysis is partitioned into frames. Each frame has a unique key with information that includes the frame kind, the creation time with the build and analysis actions that generated it. The possible frame kinds are:

CLEAN

done when eclair_env starts (unless disabled);

COMMAND

done when a command is intercepted;

UNIT

done when a translation unit is compiled;

PROGRAM

done when a program is linked;

PROJECT

done when the project as a whole is analyzed;

OBJECT

done when an object manipulation is requested;

END

done when eclair_env exits;

archive file

See library.

area kind

A report area can have one of the following kinds:

culprit

for the code responsible for the report;

evidence

for any evidential code;

context

for the code context when this is relevant to the report.

assembler

A program that transforms assembly instruction mnemonics and directives into an object file.

assembly

Generic name to indicate a low-level computer programming language. In assembly languages, binary machine codes, registers, constants and other entities needed to program a given CPU architecture are given symbolic/mnemonic representations.

AST

Abbreviation of abstract syntax tree, which is a tree representation of the abstract syntactic structure of a program in source form. The AST is abstract in the sense that it does not represent every detail of the real, concrete syntax. For instance, horizontal and vertical space and punctuation that does not convey any semantic information is only implicitly present in that tree structure.

batch file

In Microsoft Windows, a batch file is a type of script file, that is, a text file containing a sequence of commands to be executed by the command interpreter.

canonical pathname

Once symbolic links are resolved, if the file is below the project top source directory, this canonical pathname is relative to this directory, otherwise it is the absolute path to the file. Note that the path separator is always /.

caution report

A report produced by a coding rule checker that gives details about a symptom (a.k.a. code smell) that possibly indicates the presence of a non-compliance or some other danger or problem with the code.

checker

See coding rule checker.

coding rule checker

An ECLAIR service that assists in proving that a program complies to one or more coding rules. Checkers are often general enough to be able to check compliance with respect to several, possibly parametric coding rules. Hence, a coding rule instance is implemented by a particular configuration of a coding rule checker.

coding rule instance

A coding rule supplemented with an actual value for each of its parameters. For example, the rule

Do not write functions with an excessive McCabe Cyclomatic Complexity.

is parametric on the maximum value that the complexity measure can take.

coding rule

A coding rule for a programming language is a restriction that defines a subset of that programming language. For example, the rule

Do not use the character sequence /* within a comment.

ensures that each comment is clearly delineated without any misunderstanding as to what it includes.

commit

a commit is a snapshot of the repository at a specific point in time, taken by a specific author.

compiler

A program or set of programs that transforms source code written in a programming language (called the source language) into another programming language (called the target language). Most common C and C++ compilers compile the source language to assembly language for the target platform.

context

a code fragment showing the context for the non-compliance of the culprit with respect to a coding rule; indicating the relation between the culprit and any evidence.

culprit

the code fragment that causes non-compliance with respect to a coding rule.

Cygwin

A largely POSIX-compliant development and run-time environment for Microsoft Windows.

dictionary

In this document, a dictionary is a list of words along with their relative frequencies in some corpus. A project dictionary is a dictionary of words allowed in a specific project. A context dictionary is a larger dictionary of words from the application domain(s) that constitute the context of the project. These dictionaries are used to help define a project vocabulary.

ECLAIR diagnostics output

An output sink receiving ECLAIR diagnostics output. By default, this is the standard error output stream, but can be changed: the preferred way to do this is via the ECLAIR_DIAGNOSTICS_OUTPUT environment variable.

ECLAIR ancillary service

An ECLAIR service that supports other ECLAIR services; these supported services are usually reporting on multiple issues; each separate issue being handled by a distinct ancillary service.

ECLAIR metric

An ECLAIR-based software artifact that assists the user in computing some software metric.

ECLAIR service

An ECLAIR-based software artifact that assists the user in some software verification, analysis or manipulation activity. Example of services are a coding rule checkers and metric computers.

ECLAIR workspace

The directory containing various files used internally by ECLAIR. The default directory is .eclair in the user’s home directory, but can be changed with the ECLAIR_WORKSPACE environment variable.

ECL

Abbreviation of ECLAIR Command Language, which is a language for specifying command line arguments as parameters for the ECLAIR environment. Files containing ECL commands can be used with the eval_file option (see Section Configuration).

error report

A report that signals an ECLAIR parse error. NOTE: this is a very critical condition that invalidates the result of any analysis.

evidence

a code fragment showing evidence for the non-compliance of the culprit with respect to a coding rule.

executable program

Any collection of machine code instructions ready to be loaded for execution on a given CPU architecture.

false negative

When a program verification tool (any such tool) does not issue a warning concerning a piece of code that the user believes to have a problem, the user calls that a false negative. False negatives can be caused by:

  • a mismatch between the user and the tool on the interpretation of problem (example: the user believes that a coding rule forbids all integer overflows whereas the tool has been configured to flag only those involving signed integers);

  • a bug in the tool.

See false positive.

false positive

When a program verification tool (any such tool) issues a warning concerning a possible problem in a piece of code that the user believes to be OK, the user calls that a false positive. False positives can be caused by:

  • a mismatch between the user and the tool on the interpretation of problem (example: the user believes that a coding rule only forbids certain explicit casts, while the tool has been configured to flag both implicit and explicit casts);

  • a fundamental law of nature (example: due to the well known undecidability results, every C/C++ analysis tool meant to detect divisions by zero without any false negative will, by necessity, have false positives);

  • a bug in the tool.

See false negative.

first file

This is the file pointed to by the first main area of the report.

fully qualified name

The name of an entity prefixed by the fully qualified name of its context and, if applicable, suffixed by its function signature.

IDE

Abbreviation of Integrated Development Environment, which is a software application that provides an integrated user-friendly framework for development. Typically, it consists of code editors, compilers, debuggers, and any other tools that can speed up the development.

impact property

This a call function property and can be one of:

const, fp_const, pure, noeffect, nothrow, any

See -call_properties option for more details.

information report

A report produced by a coding rule checker that gives information about the analyzed code that can be of help for understanding the code, its translation process, and its run-time behavior.

installation prefix

This is the prefix leading to the installation directory of ECLAIR. If that is PREFIX, version VERSION of ECLAIR is installed in a directory tree rooted at PREFIX/eclair-VERSION (see the section about installation on a Un*x-like system) or PREFIX\eclair-VERSION (see the section about installation on a Windows platform). On platforms supporting symbolic links, the installation of version VERSION of ECLAIR makes PREFIX/eclair a symbolic link to PREFIX/eclair-VERSION.

instantiation

when any report item in a violation report has been produced by (a chain of) C++ template instantiation, this shows the code fragment that caused the instantiation of the template.

JSON

JSON (JavaScript Object Notation) [33] is a lightweight, text-based, language-independent syntax for defining data interchange formats. It is programming language independent using conventions that are familiar to programmers of the C-family of languages. JSON [33] defines a small set of structuring rules for the portable representation of structured data.

language extension

A language extension may be any feature of the source code that is outside the applicable language standard. Whether it can be meaningfully considered an extension (as opposed to being, e.g., an undiagnosed syntax or constraint violation) depends on multiple factors, including:

  • its precise semantics (it is quite common that different compilers attach a different semantics to extensions that have similar or even identical syntax);

  • the amount and accuracy of the available documentation;

  • when some sort of compiler validation is required, the availability of enough test cases and procedures that enable reaching the desired level of confidence in the compiler behavior in presence of the extension.

Note that ECLAIR provides that configure option behavior for the related ancillary services that allows a user to specify those non-standard features that should be considered as compiler extensions.

lexical item

A lexical item is a single word or chain of words possibly intermixed with non-alphabetic graphic characters. A set of lexical items is a vocabulary.

librarian

A program that allows to add/delete/replace one or more object files to/from/in a library or archive file.

library

A collection of object files along with the necessary meta-data to operate upon them. Also called an archive file.

linker

A program that takes one or more object files and libraries and combines them into an executable program.

location

A location is a position or a range of positions in the program text where the report area relevant source is located.

logical source lines of code

(LSLOCS) Logical source lines of code. Even though the actual definition is more complex than that, for C-like programming languages the LSLOCS measure roughly corresponds to the number of statement-terminating semicolons. More precisely:

  • each declaration and each statement is counted once so that a single logical statement that extends over five physical lines counts as one line;

  • if more than one declaration or statement is on a physical line, then each statement is counted separately;

  • comments (whole or embedded) and blank lines are not counted.

loop idiom

A common coding iteration construct, often defined as a macro; this has a rigid form, so that the programmer intention can be conveyed without any ambiguity. Some common idioms are:

do-while-zero

A do-while statement with 0 condition that is used for code encapsulation:

do {
    /* any code */
} while (0);
do-while-false

A do-while statement with a condition equivalent to 0 or false that is used for code encapsulation:

do {
    /* any code */
} while (false);

where false can be replaced by (possibly in parentheses) a configured Boolean constant that evaluates to false or 0.

while-true

A while statement with a condition equivalent to 1 or true:

do {
     /* any code */
} while (true);

where true can be replaced by (possibly in parentheses) a configured Boolean constant that evaluates to true or 1.

for-empty-head

A for statement with empty controlling expressions:

for (;;) {
    /* any code */
}
merge-request

See pull-request.

main area

A report area that is not a report subarea.

meter

See metric computer.

metric computer

An ECLAIR service that automatically computes a software metric.

metric report

A report produced by a metric computer that gives the value of a software metric for some program entity.

metric

See software metric.

MinGW

Minimalist GNU for Windows: a distribution of the GNU Compiler Collection (GCC) and GNU Binutils for use in compiling native Microsoft Windows applications.

morpheme

In linguistics, a morpheme is a speech element having a meaning or grammatical function that cannot be subdivided into further such elements.

non-compliance

An occurrence of a syntactic or semantic pattern that is prohibited by a coding rule or guideline.

object file

A file containing an organized collection of separate, named sections of machine code.

pipeline

It is the continuous integration and continuous delivery (CI/CD) concept in GitLab and Jenkins that allows automating build, test, and deployment workflows. An action can be triggered by an event on the repository or the platform.

POSIX

Abbreviation of Portable Operating System Interface for uniX, which is a collection of standards that define some of the functionality that a UN*X operating system should support. Several of these standards have been widely adopted, well beyond the UN*X world.

position

When referred to source code, this specifies a point in the source code defined by the source file name, row and column numbers.

project name

This is the primary key to the analysis data generated by ECLAIR. It must be a valid file name in the host system. It can be set using the -project_name option and defaults to unnamed. Be careful not to use the same project name for ECLAIR runs with different options that may result into the compilation of one or more shared translation units.

project top source directory

This is the absolute top source directory of the project. It can be set using the -project_root option. When set, violation report locations corresponding to files that are below this directory are given with a relative path, instead of an absolute one.

pull-request

Event that takes place in software development when a contributor/developer is ready to begin the process of merging new code changes with the main project repository. It is also referred to as a merge-request.

push

git operation that updates remote refs using local refs, while sending objects necessary to complete the given refs.

regular expression

A sequence of characters that specifies a search pattern in text. See regular expression for more details.

report area

Part of a report that points at an entity that is related with the report. This might be a portion of (possibly preprocessed) source code, an object file, or a whole project. We use the expressions main report area and main area to refer to a report area that is not a report subarea.

report category

Each report has a category that can be used by the -report_selector option. The allowed category values depend on the service and the service descriptions provide information about this field when the category is a non-empty value.

report kind

A report can have one of the following kinds:

error

an error report;

violation

a violation report;

caution

a caution report;

information

an information report;

metric

a metric report.

report subarea

This is an area of the report that conveys further preprocessor-related information about a source code area, such as the file inclusion chain, the macro expansion chain, or the preprocessed code.

report

ECLAIR output providing information about a circumstance that was detected by some ECLAIR service.

run-time debugger

A program that allows control of the execution of an executable program (e.g., by setting breakpoints) and the inspection of its memory at any program point. With proper cooperation from the compiler, a run-time debugger allows its users to interact with the program via source code concepts. For example, the memory associated to a particular source program variable can be referenced via the variable name.

runner

Application that runs the job contained in the actions that come from CI/CD systems.

SARIF

is a Static Analysis Results Interchange Format (SARIF) based on JSON and approved as an OASIS standard.

segmentation

The process whereby program identifiers are split into the constituent morphemes. For example: segmentation of throw_exception can give “throw exception”; segmentation of LinkedList can give “Linked List”; segmentation of JCImport can give “JC Import”; segmentation of isleastfixpoint can give “is least fixpoint”.

service kind

A service can have one of the following kinds:

rule

a checker for a coding rule;

meter

a metric computer;

parser

a language parser used by the analyzer;

reporter

a report output producer;

tool

a service not classifiable by the above kinds.

shell script

In Unix-like systems, a shell script is a type of script file, that is, a text file containing a sequence of commands to be executed by a command interpreter generically called Unix shell. The most common Unix shells are derivatives of the Bourne shell, particularly the variant called bash, from Bourne-Again shell.

single translation unit checker

A checker that, in order to fully check for compliance, can check each translation unit in isolation.

software metric

A quantitative measure of some property of a piece of software.

source code

Any collection of statements or declarations written in some human-readable computer programming language. In this document source code refers to C or C++ code unless otherwise noted.

source file name

The source code file name including the path to the file. The path that is included with the file identifier depends on the indicated style of source file name: if absolute then this path is the absolute path to the file; if canonical then, it is the canonical pathname. Note that, in both cases, the path separator is always /.

source lines of code

Software metric used to measure the size of a program’s source code by counting the number of physical source lines of code (LINES) or logical source lines of code (LSLOCS). The obvious disadvantage of the LINES measure is that it is sensitive to logically irrelevant formatting and style conventions.

standard output

The stream where a program writes its normal output data. In Un*x-like systems can be redirected to a file or a program.

stdout

See standard output.

strictness

A service category defined by the source that indicates the seriousness of the rule. Note that terminology for these categories depends on the source, but examples are mandatory, required and advisory.

subarea kind

One of:

  • expanded, for the macro expanded code;

  • preprocessed, for the preprocessed source code;

tag domain

A report is associated to a set of tags representing properties of the report; the tags for a report are grouped into domains:

dir

the tags are the directories of each area/subarea

file

the tags are the files for each area/subarea

service

the tag is the service

first_dir

the tag is the directory of the first area

first_file

the tag is the file of the first area

strictness

the tag is the strictness for the service

tag

this is the default domain for tags with no other domain.

Each report must have at one or more tags for each domain. If a report has no specified tag in a domain it is given the default tag _NO_TAG for that domain. if the special tag hide is applicable to a report, then that report will be hidden.

TOML

Abbreviation of Tom’s Obvious Minimal Language, which is a minimal configuration language in a format that is both human-readable and machine-readable and that maps unambiguously to a hash table.

toolchain

In software development, a toolchain is a set of tools that are used to create an executable piece of software, whether it be a complete program or a library. It is a chain in the sense that usually the output of a tool is the input of another tool: the editor is used to produce a source program that the compiler translates into assembly code that an assembler translates into relocatable code, an librarian combines different relocatable modules into a library, a linker combines different relocatable modules and libraries into an executable program and the latter can be used within a run-time debugger.

violation report

A report produced by a coding rule checker that gives details about non-compliance with respect to one of the coding rules being checked. A violation report will usually consist of a set of messages describing the culprit, any evidence and, where useful, the context.

vocabulary

In this document, the project vocabulary is the set of lexical items that are allowed to occur in a software project. In ECLAIR, the vocabulary is defined by means of several (optional) components, including dictionaries, regular expressions and explicit lists of allowed or disallowed items.

whole program checker

A checker that, in order to fully check for compliance, has to check each complete program by taking into account the information that collected for all translation units that are linked together in the program.

whole project checker

A checker that, in order to fully check for compliance, has to check the entire project and, in turn, each complete program constituting the project and each translation unit that is built as part of the project build, whether or not that translation unit is linked into one or more programs.

XML

Abbreviation of eXtensible Markup Language, which is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.

YAML

Abbreviation of YAML Ain’t a Markup Language, which is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.

References

[1]

VV. AA. JSF Air vehicle C++ coding standards for the system development and demonstration program. Document 2RDU00001, Rev C, Lockheed Martin Corporation, December 2005.

[2]

VV. AA. DELPHI C coding standards. SW REF 264.15D, Delphi Technologies, Inc., March 2006.

[3]

VV. AA. JPL institutional coding standard for the C programming language. Technical Report JPL DOCID D-60411, Jet Propulsion Laboratory, California Institute of Technology, March 2009.

[4]

R. Bagnara, A. Bagnara, A. Benedetti, and P. M. Hill. The ACPATH metric: precise estimation of the number of acyclic paths in C-like languages. Report 1610.07914 [cs.SE], 2016. Available at http://arxiv.org/.

[5]

R. Bagnara, A. Bagnara, and P. M. Hill. A rationale-based classification of MISRA C guidelines. In DESIGN&ELEKTRONIK, editor, embedded world Conference 2022 — Proceedings, 440–451. Nuremberg, Germany, 2022. WEKA FACHMEDIEN, Richard-Reitzner-Allee 2, 85540 Haar, Germany.

[6]

R. Bagnara, A. Bagnara, and P. M. Hill. Coding guidelines and undecidability. In DESIGN&ELEKTRONIK, editor, embedded world Conference 2023 — Proceedings, 488–499. Nuremberg, Germany, 2023. WEKA FACHMEDIEN, Richard-Reitzner-Allee 2, 85540 Haar, Germany.

[7]

M. Barr. Embedded C Coding Standard. Barr Group, www.barrgroup.com, 2013.

[8]

M. Barr. BARR-C:2018 — Embedded C Coding Standard. Barr Group, www.barrgroup.com, 2018.

[9]

D. L. Brandt. Quality measures in design: finding problems before coding. SIGSOFT Software Engineering Notes, 15(1):68–72, 1990.

[10]

P. Briand, M. Brochet, T. Cambois, E. Coutenceau, O. Guetta, D. Mainberte, F. Mondot, P. Munier, L. Noury, P. Spozio, and F. Retailleau. Software quality objectives for source code. In ERTS2 2010, Embedded Real Time Software & Systems. Toulouse, France, 2010. Available at https://hal.archives-ouvertes.fr/hal-02267695/file/3D-2.pdf.

[11]

O. Callot. Revised c++ coding conventions. Technical Report LHCb-2001-054, Laboratoire de l'Accélérateur Linéaire, Orsay, France, April 2001.

[12]

J. Dern. Embedded Software: Striving for Excellence in Development. Books on Demand GmbH, Norderstedt, Germany, 2015. ISBN 9782322017225. New revised and supplemented edition translated from \cite Dern14.

[13]

H. Kuder et al. HIS source code metrics. Technical Report HIS-SC-Metriken.1.3.1-e, Herstellerinitiative Software, April 2008. Version 1.3.1.

[14]

R. C. Seacord et al. The CERT C++ secure coding standard. Under development on the secure coding wiki at http://www.securecoding.cert.org/, 2013.

[15]

R. C. Seacord et al. The CERT C secure coding standard. Under development on the secure coding wiki at http://www.securecoding.cert.org/, 2013.

[16]

ESA Board for Software Standardisation and Control (BSSC). C and c++ coding standards. Technical Report BSSC(2000)1, European Space Agency, March 2000.

[17]

The Programming Research Group. High-Integrity C++ Coding Standard Manual. Hersham, Surrey KT12 5LU, UK, December 2006.

[18]

W. A. Harrison. Applying Mccabe's complexity measure to multiple-exit programs. Software: Practice and Experience, 14(10):1004–1007, 1984.

[19]

L. Hatton. EC–: a measurement based safer subset of ISO C suitable for embedded system development. Information and Software Technology, 4(3):181–187, 2005. doi:10.1016/j.infsof.2004.08.001.

[20]

M. Henricson and E. Nyquist. Industrial Strength C++. The SEI Series in Software Engineering. Prentice Hall PTR, 1997. ISBN 0-13-120965-5.

[21]

T. Hoff. C++ coding standard. Available at http://www.possibility.com/Cpp/, March 2008.

[22]

T. Hoff. Qt coding style. Available at http://developer.qt.nokia.com/wiki/Qt_Coding_Style, April 2013.

[23]

G. J. Holzmann. The power of ten – rules for developing safety critical code. IEEE Computer, 39(6):95–97, 2006.

[24]

J.-L. Letouzey. The SQALE method: definition document. Technical Report, DNV IT GS France, January 2012. Version 1.0.

[25]

T. J. McCabe. A complexity measure. IEEE Transactions on Software Engineering, 2(4):308–320, 1976.

[26]

B. A. Nejmeh. NPATH: a measure of execution path complexity and its applications. Communications of the ACM, 31(2):188–200, 1988.

[27]

R. C. Seacord. The CERT C Secure Coding Standard. The SEI Series in Software Engineering. Addison Wesley Professional, 2008. ISBN 0-321-56321-2.

[28]

R. C. Seacord. The CERT C Coding Standard: 98 Rules for Developing Safe, Reliable, and Secure Systems. Addison-Wesley Professional, second edition, 2014.

[29]

B. Weinberger, C. Silverstein, G. Eitzmann, M. Mentovai, and T. Landray. Google C++ Style Guide. Google, revision 3.180 edition. Available at http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.

[30]

AUTOSAR. Specification of C implementation rules. Technical Report, AUTOSAR, December 2009.

[31]

CCB Coding Standards Philips Healthcare. Philips Healthcare — C++ Coding Standard. August 2010.

[32]

CERT. SEI CERT C Coding Standard: Rules for Developing Safe, Reliable, and Secure Systems. Software Engineering, Carnegie Mellon University, 2016 edition, 2016.

[33]

Ecma International. The JSON data interchange syntax. Available at https://www.ecma-international.org/publications-and-standards/standards/ecma-404/, December 2017. 2nd Edition.

[34]

ISO/IEC. ISO/IEC 9899:1990: Programming Languages — C. ISO/IEC, Geneva, Switzerland, 1990.

[35]

ISO/IEC. ISO/IEC 9899:1990/AMD 1:1995: Programming Languages — C. ISO/IEC, Geneva, Switzerland, 1995.

[36]

ISO/IEC. ISO/IEC 14882:1998: Programming languages — C++. ISO/IEC, Geneva, Switzerland, 1998.

[37]

ISO/IEC. ISO/IEC 9899:1999: Programming Languages — C. ISO/IEC, Geneva, Switzerland, 1999.

[38]

ISO/IEC. ISO/IEC 14882:2003: Programming languages — C++. ISO/IEC, Geneva, Switzerland, 2003.

[39]

ISO/IEC. ISO/IEC 14882:2011: Programming languages — C++. ISO/IEC, Geneva, Switzerland, 2011.

[40]

ISO/IEC. ISO/IEC 9899:2011: Programming Languages — C. ISO/IEC, Geneva, Switzerland, 2011.

[41]

ISO/IEC. ISO/IEC 14882:2014: Programming languages — C++. ISO/IEC, Geneva, Switzerland, 2014.

[42]

ISO/IEC. ISO/IEC 14882:2017: Programming languages — C++. ISO/IEC, Geneva, Switzerland, 2017.

[43]

ISO/IEC. ISO/IEC 9899:2018: Programming Languages — C. ISO/IEC, Geneva, Switzerland, 2018.

[44]

ISO/IEC. ISO/IEC 14882:2020: Programming languages — C++. ISO/IEC, Geneva, Switzerland, 2020.

[45]

MISRA. MISRA C:2012 — Guidelines for the use of the C language in critical systems. MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, March 2013.

[46]

MISRA. MISRA C:2012 Amendment 1 — Additional security guidelines for MISRA C:2012. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, April 2016.

[47]

MISRA. MISRA Compliance:2016 — Achieving compliance with MISRA Coding Guidelines. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, April 2016.

[48]

MISRA. MISRA C:2012 Technical Corrigendum 1 — Technical clarification of MISRA C:2012. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, June 2017.

[49]

MISRA. MISRA C:2012 Addendum 2 — Coverage of MISRA C:2012 (including Amendment 1) against ISO/IEC TS 17961:2013 “C Secure”. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, 2nd edition, January 2018.

[50]

MISRA. MISRA C:2012 Addendum 3 — Coverage of MISRA C:2012 (including Amendment 1) against CERT C 2016 Edition. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, January 2018.

[51]

MISRA. MISRA C:2012 — Guidelines for the use of the C language critical systems. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, February 2019. Third edition, first revision.

[52]

MISRA. MISRA C:2012 Amendment 2 — Updates for ISO/IEC 9899:2011 Core functionality. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, February 2020.

[53]

MISRA. MISRA C:2012 Permits. HORIBA MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, 1 edition, March 2021.

[54]

MISRA. MISRA C:2012 Technical Corrigendum 2 — Technical clarification of MISRA C:2012. The MISRA Consortium Limited, Norwich, Norfolk NR3 1RU, UK, March 2022.

[55]

MISRA. MISRA C:2012 Amendment 3 — Updates for ISO/IEC 9899:2011/2018 Phase 2 — New C11/C18 features. The MISRA Consortium Limited, Norwich, Norfolk NR3 1RU, UK, October 2022.

[56]

MISRA. MISRA C++:2023 — Guidelines for the use of C++17 in critical systems. The MISRA Consortium Limited, Norwich, Norfolk, NR3 1RU, UK, October 2023.

[57]

MISRA. MISRA C:2012 Amendment 4 — Updates for ISO/IEC 9899:2011/2018 Phase 3 — Multi-threading and atomics. The MISRA Consortium Limited, Norwich, Norfolk NR3 1RU, UK, March 2023.

[58]

MISRA. MISRA C:2023 — Guidelines for the use of the C language in critical systems. The MISRA Consortium Limited, Norwich, Norfolk, NR3 1RU, UK, April 2023. Third edition, second revision.

[59]

MISRA. MISRA C:2025 — Guidelines for the use of the C language in critical systems. The MISRA Consortium Limited, Norwich, Norfolk, NR3 1RU, UK, March 2025.

[60]

Motor Industry Software Reliability Association. MISRA-C:1998 — Guidelines for the use of the C language in critical systems. MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, April 1998.

[61]

Motor Industry Software Reliability Association. MISRA-C — Technical Clarification Document 25th July 2000. MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, July 2000.

[62]

Motor Industry Software Reliability Association. MISRA-C:2004 — Guidelines for the use of the C language in critical systems. MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, October 2004.

[63]

Motor Industry Software Reliability Association. MISRA-C:2004 — Technical Corrigendum 1. MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, July 2007.

[64]

Motor Industry Software Reliability Association. MISRA C++:2008 — Guidelines for the use of the C++ language in critical systems. MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, June 2008.

[65]

Motor Industry Software Reliability Association. MISRA C:2004 Permits. MIRA Limited, Nuneaton, Warwickshire CV10 0TU, UK, 1 edition, April 2016.

[66]

Software Engineering Center. Embedded System Development Coding Reference Guide: C Language Edition. Information-Technology Promotion Agency, Japan, March 2012. Version 1.1.

[67]

Software Engineering Center. Embedded System Development Coding Reference Guide: C++ Language Edition. Information-Technology Promotion Agency, Japan, March 2013. Version 1.0.

[68]

Software Reliability Enhancement Center. Embedded System Development Coding Reference Guide: C Language Edition. Information-Technology Promotion Agency, Japan, July 2014. Version 2.0.

[69]

The GeantV Team. Geant coding standards. Available at http://geant.cern.ch/content/coding-standards, 2014.

[70]

The ROOT Team. C++ coding conventions. Available at http://root.cern.ch/drupal/content/c-coding-conventions, 2011.

[71]

The ROOT Team. ROOT C++ naming and style rules. Available at http://root.cern.ch/root/nightly/codecheck/rules.html, 2011.

[72]

United States Election Assistance Commission. Voting System Performance Guidelines, Version 1.1. 2015.